Logging
Log files
Neo4j provides logs for monitoring purposes.
The root directory where the general log files are located is configured by dbms.directories.logs
.
For more information on where files are located, see File locations.
The following table describes the Neo4j general log files and the information they contain.
Filename | Description |
---|---|
neo4j.log |
The user log, where general information about Neo4j is written. Not written for Debian and RPM packages. |
debug.log |
The debug log, log information useful when debugging problems with Neo4j. |
http.log |
The HTTP log, log for the HTTP API. |
gc.log |
The garbage collection log, logging provided by the JVM. |
query.log |
The query log, log of executed queries that takes longer than a specified threshold. Enterprise |
security.log |
The security log, log of security events. Enterprise |
service-error.log |
The windows service log, log of errors encountered when installing or running the Windows service. Windows |
Configuration setting | Default value | Description |
---|---|---|
|
Path of the logs directory. |
|
|
Path to the user log file. |
|
|
Path to the debug log file. |
|
|
Path to HTTP log file. |
|
|
Path to the query log file. |
|
|
Path to the security log file. |
User log
The user log configuration | Default value | Description |
---|---|---|
|
The minimum time interval after last rotation of the user log, before it may be rotated again. |
|
|
The maximum number of history files for the user log. |
|
|
The threshold size for rotation of the user log.
If set to |
|
|
Send user logs to the process stdout. If this is disabled then logs will instead be sent to the user log (neo4j.log). |
Debug log
The debug log configuration | Default value | Description |
---|---|---|
|
Log level threshold for the debug log. |
|
|
The minimum time interval after last rotation of the debug log, before it may be rotated again. |
|
|
The maximum number of history files for the debug log. |
|
|
The threshold size for rotation of the debug log. |
The following table lists all message types raised by Neo4j and their severity level:
Message type | Severity level | Description |
---|---|---|
|
Low severity |
Report status information and errors that are not severe. |
|
Low severity |
Report details on the raised errors and possible solutions. |
|
Low severity |
Report errors that need attention but are not severe. |
|
High severity |
Report errors that prevent the Neo4j server from running and must be addressed immediately. |
To set the log level threshold for the debug log use the configuration setting dbms.logs.debug.level
.
Garbage collection log
The garbage collection log configuration | Default value | Description |
---|---|---|
|
Enable garbage collection logging. |
|
Garbage collection logging options. |
||
|
The maximum number of history files for the garbage collection log. |
|
The threshold size for rotation of the garbage collection log. |
HTTP log
The HTTP log configuration | Default value | Description |
---|---|---|
|
Enable HTTP logging. |
|
|
The maximum number of history files for the HTTP log. |
|
|
The threshold size for rotation of the HTTP log. |
Security log
Neo4j provides security event logging that records all security events.
For native user management, the following actions are recorded:
-
Login attempts - per default both successful and unsuccessful logins are recorded.
-
All administration commands run towards the system database.
-
All security procedures run towards the system database.
Security log configuration
Rotation of the security events log can be configured in the neo4j.conf configuration file.
The following configuration settings are available for the security log:
The security log configuration | Default value | Description |
---|---|---|
|
Security log level threshold. |
|
|
The name of the security log file. |
|
|
Sets the file size at which the security event log will auto-rotate. |
|
|
The minimum time interval after the last security log rotation occurred, before the security log may be rotated again. |
|
|
The number of historical log files kept. |
If using LDAP as the authentication method, some cases of LDAP misconfiguration will also be logged, as well as LDAP server communication events and failures.
If many programmatic interactions are expected, it is advised to disable the logging of successful logins.
Logging of successful logins is disabled by setting the dbms.security.log_successful_authentication
parameter in the neo4j.conf
file:
dbms.security.log_successful_authentication=false
Example output for a security log:
2019-12-09 13:45:00.796+0000 INFO [AsyncLog @ 2019-12-09 ...] [johnsmith]: logged in
2019-12-09 13:47:53.443+0000 ERROR [AsyncLog @ 2019-12-09 ...] [johndoe]: failed to log in: invalid principal or credentials
2019-12-09 13:48:28.566+0000 INFO [AsyncLog @ 2019-12-09 ...] [johnsmith]: CREATE USER janedoe SET PASSWORD '******' CHANGE REQUIRED
2019-12-09 13:48:32.753+0000 INFO [AsyncLog @ 2019-12-09 ...] [johnsmith]: CREATE ROLE custom
2019-12-09 13:49:11.880+0000 INFO [AsyncLog @ 2019-12-09 ...] [johnsmith]: GRANT ROLE custom TO janedoe
2019-12-09 13:49:34.979+0000 INFO [AsyncLog @ 2019-12-09 ...] [johnsmith]: GRANT TRAVERSE ON GRAPH * NODES A, B (*) TO custom
2019-12-09 13:49:37.053+0000 INFO [AsyncLog @ 2019-12-09 ...] [johnsmith]: DROP USER janedoe
Query log
Neo4j can be configured to log queries executed in the database.
Query logging is enabled by default and is controlled by the setting dbms.logs.query.enabled
.
Configuration options are:
Option | Description |
---|---|
|
Will completely disable logging. |
|
Will log at the end of queries that have either succeeded or failed.
The |
|
Will log all queries at both start and finish, regardless of |
Query log configuration
The name of the query log file is query.log
by default, (see dbms.logs.query.path
).
Rotation of the query log can be configured in the neo4j.conf configuration file.
The following configuration settings are available for the query log file:
The query log configuration | Default value | Description |
---|---|---|
|
Log allocated bytes for the executed queries being logged.
The logged number is cumulative over the duration of the query, i.e. for memory intense or long-running queries the value may be larger than the current memory allocation.
Requires |
|
|
Log query text and parameters without obfuscating passwords. This allows queries to be logged earlier before parsing starts. |
|
|
Log executed queries. |
|
|
Log page hits and page faults for the executed queries being logged. |
|
|
Log complete parameter entities including ID, labels or relationship type, and properties.
If |
|
|
Log parameters for the executed queries being logged. |
|
|
The maximum number of history files for the query log. |
|
|
The file size in bytes at which the query log will auto-rotate. |
|
|
Logs which runtime that was used to run the query. |
|
|
If the execution of query takes a longer time than this threshold, the query is logged once completed (provided query logging is set to |
|
|
Log detailed time information for the executed queries being logged.
Requires |
In this example we set query logging to INFO
, but leave all other query log parameters at their defaults.
dbms.logs.query.enabled=INFO
Below is an example of the query log with this basic configuration:
2017-11-22 14:31 ... INFO 9 ms: bolt-session bolt johndoe neo4j-javascript/1.4.1 client/127.0.0.1:59167 ...
2017-11-22 14:31 ... INFO 0 ms: bolt-session bolt johndoe neo4j-javascript/1.4.1 client/127.0.0.1:59167 ...
2017-11-22 14:32 ... INFO 3 ms: server-session http 127.0.0.1 /db/data/cypher neo4j - CALL dbms.procedures() - {}
2017-11-22 14:32 ... INFO 1 ms: server-session http 127.0.0.1 /db/data/cypher neo4j - CALL dbms.showCurrentUs...
2017-11-22 14:32 ... INFO 0 ms: bolt-session bolt johndoe neo4j-javascript/1.4.1 client/127.0.0.1:59167 ...
2017-11-22 14:32 ... INFO 0 ms: bolt-session bolt johndoe neo4j-javascript/1.4.1 client/127.0.0.1:59167 ...
2017-11-22 14:32 ... INFO 2 ms: bolt-session bolt johndoe neo4j-javascript/1.4.1 client/127.0.0.1:59261 ...
In this example we turn query logging on, and also enable some additional logging.
dbms.logs.query.parameter_logging_enabled=true
dbms.logs.query.time_logging_enabled=true
dbms.logs.query.allocation_logging_enabled=true
dbms.logs.query.page_logging_enabled=true
Below is an example of the query log with these configuration parameters enabled:
2017-11-22 12:38 ... INFO 3 ms: bolt-session bolt johndoe neo4j-javascript/1.4.1 ...
2017-11-22 22:38 ... INFO 61 ms: (planning: 0, cpu: 58, waiting: 0) - 6164496 B - 0 page hits, 1 page faults ...
2017-11-22 12:38 ... INFO 78 ms: (planning: 40, cpu: 74, waiting: 0) - 6347592 B - 0 page hits, 0 page faults ...
2017-11-22 12:38 ... INFO 44 ms: (planning: 9, cpu: 25, waiting: 0) - 1311384 B - 0 page hits, 0 page faults ...
2017-11-22 12:38 ... INFO 6 ms: (planning: 2, cpu: 6, waiting: 0) - 420872 B - 0 page hits, 0 page faults - ...
Attach metadata to a transaction
You can attach metadata to a transaction and have it printed in the query log, using the built-in procedure tx.setMetaData
.
Neo4j Drivers also support attaching metadata to a transaction. For more information, see the respective Driver’s manual. |
Every graph-app should follow a convention for passing metadata with the queries that it sends to Neo4j:
{
app: "neo4j-browser_v4.1.11", (1)
type: "system" (2)
}
1 | app could be a user-agent styled name plus version. |
2 | type could be one of:
|
This is typically done programmatically but can also be used with the Neo4j dev tools.
In general, you start a transaction on a user database and attach a list of metadata to it by calling tx.setMetaData
.
You can also use the procedure CALL tx.getMetaData()
to show the metadata of the current transaction.
These examples use the MovieGraph dataset from the Neo4j Browser guide.
cypher-shell
, attach metadata to a transactionneo4j@neo4j> :begin
neo4j@neo4j# CALL tx.setMetaData({app: 'neo4j-cypher-shell_v.4.1.11', type: 'user-direct', user: 'jsmith'});
0 rows
ready to start consuming query after 2 ms, results consumed after another 0 ms
neo4j@neo4j# CALL tx.getMetaData();
+--------------------------------------------------------------------------+
| metadata |
+--------------------------------------------------------------------------+
| {app: "neo4j-cypher-shell_v.4.1.11", type: "user-direct", user: "jsmith"} |
+--------------------------------------------------------------------------+
1 row
ready to start consuming query after 37 ms, results consumed after another 2 ms
neo4j@neo4j# MATCH (n:Person) RETURN n LIMIT 5;
+----------------------------------------------------+
| n |
+----------------------------------------------------+
| (:Person {name: "Keanu Reeves", born: 1964}) |
| (:Person {name: "Carrie-Anne Moss", born: 1967}) |
| (:Person {name: "Laurence Fishburne", born: 1961}) |
| (:Person {name: "Hugo Weaving", born: 1960}) |
| (:Person {name: "Lilly Wachowski", born: 1967}) |
+----------------------------------------------------+
5 rows
ready to start consuming query after 2 ms, results consumed after another 1 ms
neo4j@neo4j# :commit
2021-07-30 14:43:17.176+0000 INFO id:225 - 2 ms: 136 B - bolt-session bolt neo4j-cypher-shell/v4.1.11 client/127.0.0.1:54026 server/127.0.0.1:7687> neo4j - neo4j -
MATCH (n:Person) RETURN n LIMIT 5; - {} - runtime=pipelined - {app: 'neo4j-cypher-shell_v.4.1.11', type: 'user-direct', user: 'jsmith'}
CALL tx.setMetaData({app: 'neo4j-browser_v.4.1.11', type: 'user-direct', user: 'jsmith'});
MATCH (n:Person) RETURN n LIMIT 5
2021-07-30 14:51:39.457+0000 INFO Query started: id:328 - 0 ms: 0 B - bolt-session bolt neo4j-browser/v4.1.11 client/127.0.0.1:53666 server/127.0.0.1:7687> neo4j - neo4j - MATCH (n:Person) RETURN n LIMIT 5 - {} - runtime=null - {type: 'system', app: 'neo4j-browser_v4.1.11'}
CALL tx.setMetaData({app: 'neo4j-browser_v.1.7.0', type: 'user-direct', user: 'jsmith'})
MATCH (n:Person) RETURN n LIMIT 5
2021-07-30 15:09:54.048+0000 INFO id:95 - 1 ms: 72 B - bolt-session bolt neo4j-bloom/v1.7.0 client/127.0.0.1:54693 server/127.0.0.1:11003> neo4j - neo4j - RETURN TRUE - {} - runtime=pipelined - {app: 'neo4j-bloom_v1.7.0', type: 'system'}
In Neo4j Browser and Bloom, the user-provided metadata is always replaced by the system metadata. |