Skip to content

Commit 778e581

Browse files
Update the logging page for 2025.01 (#2063)
Co-authored-by: MishaDemianenko <[email protected]>
1 parent 7db1405 commit 778e581

File tree

1 file changed

+82
-57
lines changed

1 file changed

+82
-57
lines changed

modules/ROOT/pages/monitoring/logging.adoc

Lines changed: 82 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ For Debian and RPM packages run `journalctl --unit=neo4j`.
2929
| Log information required by Neo4j Customer Support to investigate problems.
3030
It is highly recommended to keep it enabled and not to alter the _debug.log_ format.
3131
If you require the _debug.log_ messages in a different format, create an additional Appender.
32+
Starting from Neo4j 2025.01, the default format is JSON.
3233
| xref:configuration/configuration-settings.adoc#config_server.logs.debug.enabled[`server.logs.debug.enabled`]
3334
| `true`
3435

@@ -80,15 +81,19 @@ and xref:configuration/configuration-settings.adoc#config_db.logs.query.threshol
8081
Neo4j uses https://logging.apache.org/log4j/2.x/[Log4j 2] for logging.
8182
The logging configuration is located in the _conf_ directory and consists of two files:
8283

83-
* _user-log.xml_ -- provides configuration for _neo4j.log_.
84+
* _user-logs.xml_ -- provides configuration for _neo4j.log_.
8485
* _server-logs.xml_ -- provides configuration for _debug.log_, _http.log_, _query.log_, and _security.log_.
8586

8687
The _gc.log_ is handled by the Java Virtual Machine(JVM) and is configured using the JVM parameters.
8788
For details, see <<garbage-collection-log-file-configuration>>.
8889

89-
[TIP]
90+
[json-format]
91+
[NOTE]
9092
====
91-
If you want to use a custom directory for your Log4j configuration files, set the new paths to your XML files in the _neo4j.conf_ file by using the parameters xref:configuration/configuration-settings.adoc#config_server.logs.user.config[`server.logs.user.config`] and xref:configuration/configuration-settings.adoc#config_server.logs.config[`server.logs.config`].
93+
Starting from Noe4j 2025.01, the default configuration files are located in the _server.directories.configuration=conf_ directory.
94+
Therefore, the default paths to the configuration files are _<home>/conf/user-logs.xml_ and _<home>/conf/server-logs.xml_.
95+
If you use a custom directory for your Log4j configuration files, update the paths to your XML files in the _neo4j.conf_ file to depend on <conf> rater than <home>.
96+
For example, xref:configuration/configuration-settings.adoc#config_server.logs.user.config[`server.logs.user.config=path/to/your/conf/user-logs.xml`] and xref:configuration/configuration-settings.adoc#config_server.logs.config[`server.logs.config=path/to/your/conf/server-logs.xml`].
9297
====
9398

9499
Each configuration file comprises two main elements: _Appenders_ and _Loggers_:
@@ -113,14 +118,14 @@ For more details, see https://logging.apache.org/log4j/2.x/manual/configuration.
113118

114119
The following example shows the default configuration of the _user-logs.xml_ file.
115120

116-
.Default _user-log.xml_ configuration
117-
[source%linenums,xml,options="nowrap", role="nocopy"]
121+
.Default _user-logs.xml_ configuration
122+
[source,xml,options="nowrap", role="nocopy"]
118123
----
119124
<?xml version="1.0" encoding="UTF-8"?>
120125
<!--
121126
122127
Copyright (c) "Neo4j"
123-
Neo4j Sweden AB [http://neo4j.com]
128+
Neo4j Sweden AB [https://neo4j.com]
124129
This file is a commercial add-on to Neo4j Enterprise Edition.
125130
126131
-->
@@ -138,11 +143,11 @@ The following example shows the default configuration of the _user-logs.xml_ fil
138143
<Appenders> \ #<2>
139144
<RollingRandomAccessFile name="Neo4jLog" fileName="${config:server.directories.logs}/neo4j.log" #<3>
140145
filePattern="$${config:server.directories.logs}/neo4j.log.%02i"> #<4>
141-
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSSZ}{GMT+0} %-5p %m%n"/> #<5>
142-
<Policies> \ #<6>
143-
<SizeBasedTriggeringPolicy size="20 MB"/> \ #<7>
146+
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSSZ}{GMT+0} %-5p %m%n"/> #<6>
147+
<Policies> \ #<7>
148+
<SizeBasedTriggeringPolicy size="20 MB"/> \ #<8>
144149
</Policies>
145-
<DefaultRolloverStrategy fileIndex="min" max="7"/> \ #<8>
150+
<DefaultRolloverStrategy fileIndex="min" max="7"/> \ #<9>
146151
</RollingRandomAccessFile>
147152
148153
<!-- Only used by "neo4j console", will be ignored otherwise -->
@@ -151,9 +156,9 @@ The following example shows the default configuration of the _user-logs.xml_ fil
151156
</Console>
152157
</Appenders>
153158
154-
<Loggers> \ #<9>
159+
<Loggers> \ #<10>
155160
<!-- Log level for the neo4j log. One of DEBUG, INFO, WARN, ERROR or OFF -->
156-
<Root level="INFO"> \ #<10>
161+
<Root level="INFO"> \ #<11>
157162
<AppenderRef ref="Neo4jLog"/>
158163
<AppenderRef ref="ConsoleAppender"/>
159164
</Root>
@@ -168,41 +173,47 @@ The following example shows the default configuration of the _user-logs.xml_ fil
168173
The following example shows the default configuration of the _server-logs.xml_ file.
169174

170175
.Default _server-logs.xml_ configuration
171-
[source%linenums,xml,options="nowrap", role="nocopy"]
176+
[source,xml,options="nowrap", role="nocopy"]
172177
----
173178
<?xml version="1.0" encoding="UTF-8"?>
174179
<!--
175180
176181
Copyright (c) "Neo4j"
177-
Neo4j Sweden AB [http://neo4j.com]
182+
Neo4j Sweden AB [https://neo4j.com]
178183
This file is a commercial add-on to Neo4j Enterprise Edition.
179184
180185
-->
181186
<!--
182187
This is a log4j 2 configuration file.
183188
184-
Please do not alter the original debug.log.
185-
Changing the debug.log format can interfere with Neo4j's ability to offer customer support and invalidate your support warranty.
189+
Please keep the original "debug.log" as is, to make sure enough data is captured in of case errors
190+
in a format that neo4j support engineers and developers can work with. Changing the "debug.log" format
191+
can interfere with neo4j's ability to offer customer support and invalidate your support warranty.
186192
187-
If you require the debug.log messages in a different format, you can copy the Appender and change the filename.
188-
See Neo4j documentation for details.
193+
If you require the "debug.log" messages in a different format you can copy the Appender and change the
194+
filename. See Neo4j documentation.
189195
190-
All configuration values can be queried with the lookup prefix "config:". You can, for example, resolve
196+
All configuration values can be queried with the lookup prefix "config:". You can for example, resolve
191197
the path to your neo4j home directory with ${config:dbms.directories.neo4j_home}.
192198
193199
Please consult https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions and
194200
available configuration options.
195201
-->
196202
<Configuration status="ERROR" monitorInterval="30" packages="org.neo4j.logging.log4j"> \ #<1>
197203
<Appenders> \ #<2>
198-
<!-- Neo4j debug.log,do not change. Required by Neo4j customer support. -->
204+
<!-- Neo4j debug.log, do not change. Required by Neo4j customer support. -->
199205
<RollingRandomAccessFile name="DebugLog" fileName="${config:server.directories.logs}/debug.log" \ #<3>
200206
filePattern="$${config:server.directories.logs}/debug.log.%02i"> \ #<4>
201-
<Neo4jDebugLogLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSSZ}{GMT+0} %-5p [%c{1.}] %m%n"/> \ #<5>
202-
<Policies> \ #<6>
203-
<SizeBasedTriggeringPolicy size="20 MB"/> \ #<7>
207+
<!-- JSON format -->
208+
<JsonTemplateLayout eventTemplateUri="classpath:org/neo4j/logging/StructuredLayoutWithMessage.json"/> \ #<5>
209+
210+
<!-- Text format -->
211+
<!-- <Neo4jDebugLogLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSSZ}{GMT+0} %-5p [%c{1.}] %m%n"/> --> \ #<6>
212+
213+
<Policies> \ #<7>
214+
<SizeBasedTriggeringPolicy size="20 MB"/> \ #<8>
204215
</Policies>
205-
<DefaultRolloverStrategy fileIndex="min" max="7"/> \ #<8>
216+
<DefaultRolloverStrategy fileIndex="min" max="7"/> \ #<9>
206217
</RollingRandomAccessFile>
207218
208219
<RollingRandomAccessFile name="HttpLog" fileName="${config:server.directories.logs}/http.log"
@@ -233,16 +244,16 @@ The following example shows the default configuration of the _server-logs.xml_ f
233244
</RollingRandomAccessFile>
234245
</Appenders>
235246
236-
<Loggers> \ #<9>
247+
<Loggers> \ #10>
237248
<!-- Log levels. One of DEBUG, INFO, WARN, ERROR or OFF -->
238249
239250
<!-- The debug log is used as the root logger to catch everything -->
240-
<Root level="INFO"> \ #<10>
251+
<Root level="INFO"> \ #<11>
241252
<AppenderRef ref="DebugLog"/> <!-- Keep this -->
242253
</Root>
243254
244255
<!-- The query log, must be named "QueryLogger" -->
245-
<Logger name="QueryLogger" level="INFO" additivity="false"> \ #<11>
256+
<Logger name="QueryLogger" level="INFO" additivity="false"> \ #<12>
246257
<AppenderRef ref="QueryLog"/>
247258
</Logger>
248259
@@ -277,30 +288,36 @@ See <<general-logging-appenders>> for more information.
277288
<4> `filePattern` specifies a file pattern to be used when the file is rolled.
278289
The pattern renames the files to _debug.log.01_ and _http.log.01_ when they reach the defined trigger.
279290

280-
<5> `PatternLayout` defines the layout for the appender, in this case with the `GMT+2` timezone.
291+
<5> The `JsonTemplateLayout` layout is used to format the log messages in JSON format.
292+
Starting from Neo4j 2025.01, the default _debug.log_ format is JSON, and it is recommended to keep it enabled to ensure the best support.
293+
If you require the _debug.log_ messages in a different format, create an additional Appender since the default one is used by the Neo4j Support team.
294+
If you require to use the text format, you can uncomment entry <6>.
295+
296+
<6> `PatternLayout` defines the layout for the appender, in this case, with the `GMT+2` timezone.
297+
Note that this is used in the 5.x series and is now disabled by default.
281298
See <<general-logging-log-layout>> for more information.
282299

283-
<6> The `Policies` element defines when the files are rolled and how many files to keep as history before they are deleted.
300+
<7> The `Policies` element defines when the files are rolled and how many files to keep as history before they are deleted.
284301

285-
<7> The `SizeBasedTriggeringPolicy` defines when the files are rolled.
302+
<8> The `SizeBasedTriggeringPolicy` defines when the files are rolled.
286303
In this case, when the size of the files reaches 20 MB, the files are renamed according to the `filePattern`, and the log files start over.
287304
In Neo4j 4.0, this was configured with the parameter `dbms.logs.user.rotation.size`.
288305

289-
<8> The `DefaultRolloverStrategy` defines how many files to keep as history. +
306+
<9> The `DefaultRolloverStrategy` defines how many files to keep as history. +
290307
The `fileIndex=min` implies that the minimum/the lowest number is the most recent one. +
291308
The `max` attribute defines the number of files to keep as history before they are deleted, in this case, 7 files.
292309
In Neo4j 4.0, this was configured with the parameter `dbms.logs.user.rotation.keep_number`.
293310

294-
<9> Loggers are used to define the log level and which appender to use for the log messages.
311+
<10> Loggers are used to define the log level and which appender to use for the log messages.
295312
The loggers are referenced by the `name` attribute.
296313
See <<general-logging-loggers>> for more information.
297314

298-
<10> The root logger is a "catch-all" logger that catches everything that is not caught by the other loggers and sends it to the appender(s) specified in the `AppenderRef` element(s).
315+
<11> The root logger is a "catch-all" logger that catches everything that is not caught by the other loggers and sends it to the appender(s) specified in the `AppenderRef` element(s).
299316
The root logger is referenced by the `Root` element.
300317
It can be set to `DEBUG`, `INFO`, `WARN`, `ERROR`, or `OFF`.
301318
The default log level is `INFO`.
302319

303-
<11> You can also define custom loggers to catch specific log events and send them to the appender(s) specified in the `AppenderRef` element(s).
320+
<12> You can also define custom loggers to catch specific log events and send them to the appender(s) specified in the `AppenderRef` element(s).
304321
For example, the `QueryLogger` logger (configured in _server-logs.xml_) is used to catch log events with a log level of `INFO` or above and send them to the `QueryLog` appender. +
305322
The `additivity="false"` is set to fully consume the log event and not send it to the root logger. +
306323
If `additivity="true"` is set, which is the default, the log event is also sent to the root logger.
@@ -428,23 +445,16 @@ a| `%n`
428445

429446
For all available converters, consult the https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout[Log4j 2 Pattern Layout documentation].
430447

431-
[[general-logging-debug-log-pattern]]
432-
==== `<Neo4jDebugLogLayout>`
433-
434-
The `<Neo4jDebugLogLayout>` layout is essentially the same as the xref:monitoring/logging.adoc#general-logging-pattern-layout[`PatternLayout`].
435-
The main difference is that a header is injected at the start of the log file with diagnostic information useful for Neo4j developers.
436-
This layout should typically only be used for the _debug.log_ file.
437-
438-
.An example usage of the Neo4j debug log layout
439-
[source,xml]
440-
----
441-
<Neo4jDebugLogLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSSZ}{GMT+0} %-5p [%c{1.}] %m%n"/>
442-
----
443-
444448
[[general-logging-json-template-layout]]
445449
==== `<JsonTemplateLayout>`
446-
The `<JsonTemplateLayout>` is equivalent to the pattern layout.
447-
For more information, see the https://logging.apache.org/log4j/2.x/manual/json-template-layout.html[Log4j official documentation].
450+
The `<JsonTemplateLayout>` is equivalent to the pattern layout and is used to format log messages in JSON format.
451+
452+
[NOTE]
453+
====
454+
Starting from Neo4j 2025.01, JSON is the default format for the _debug.log_.
455+
It is highly recommended not to alter the _debug.log_ format as it is required by Neo4j Customer Support to investigate problems.
456+
If you require the _debug.log_ messages in a different format, create an additional Appender.
457+
====
448458

449459
There are two ways of configuring the JSON template layout.
450460

@@ -458,7 +468,7 @@ The JSON template file can be on the file system.
458468

459469
* The JSON event template file can be embedded in the XML configuration:
460470
+
461-
[source%linenums,xml,highlight=4..12]
471+
[source,xml,highlight=4..12]
462472
----
463473
<JsonTemplateLayout>
464474
<eventTemplate>
@@ -514,6 +524,21 @@ There are also a couple of built-in templates available from the classpath, for
514524
| Same layout as the less flexible `<JsonLayout>`.
515525
|===
516526

527+
For more information, see the https://logging.apache.org/log4j/2.x/manual/json-template-layout.html[Log4j official documentation].
528+
529+
[[general-logging-debug-log-pattern]]
530+
==== `<Neo4jDebugLogLayout>`
531+
532+
The `<Neo4jDebugLogLayout>` layout is essentially the same as the xref:monitoring/logging.adoc#general-logging-pattern-layout[`PatternLayout`].
533+
The main difference is that a header is injected at the start of the log file with diagnostic information useful for Neo4j developers.
534+
This layout should typically only be used for the _debug.log_ file.
535+
536+
.An example usage of the Neo4j debug log layout
537+
[source,xml]
538+
----
539+
<Neo4jDebugLogLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSSZ}{GMT+0} %-5p [%c{1.}] %m%n"/>
540+
----
541+
517542
=== Filters
518543

519544
You can also configure filters to determine if and what log events are published and how.
@@ -575,7 +600,7 @@ The root logger is a special logger that matches everything, so if another logge
575600
Therefore, it is best practice always to include a root logger so that no log events are missed.
576601

577602
.Configuration of loggers
578-
[source%linenums,xml,options="nowrap"]
603+
[source,xml,options="nowrap"]
579604
----
580605
<Configuration>
581606
<!-- Appenders -->
@@ -684,7 +709,7 @@ dbms.security.log_successful_authentication=false
684709
The security log can use a JSON layout.
685710
To change the format, the layout for the `SecurityLogger` must be changed from using the `PatternLayout`:
686711

687-
[source%linenums,xml,options="nowrap",highlight=4]
712+
[source,xml,options="nowrap",highlight=4]
688713
----
689714
<RollingRandomAccessFile name="SecurityLog" fileName="${config:server.directories.logs}/security.log"
690715
filePattern="$${config:server.directories.logs}/security.log.%02i">
@@ -698,7 +723,7 @@ To change the format, the layout for the `SecurityLogger` must be changed from u
698723

699724
to using the `JsonTemplateLayout`:
700725

701-
[source%linenums,xml,options="nowrap",highlight=4]
726+
[source,xml,options="nowrap",highlight=4]
702727
----
703728
<RollingRandomAccessFile name="SecurityLog" fileName="${config:server.directories.logs}/security.log"
704729
filePattern="$${config:server.directories.logs}/security.log.%02i">
@@ -1131,7 +1156,7 @@ In Neo4j Browser and Bloom, the user-provided metadata is always replaced by the
11311156
The query log can use a JSON layout.
11321157
To change the format, the layout for the `QueryLogger` must be changed from using the `PatternLayout`:
11331158

1134-
[source%linenums,xml,options="nowrap",highlight=4]
1159+
[source,xml,options="nowrap",highlight=4]
11351160
----
11361161
<RollingRandomAccessFile name="QueryLog" fileName="${config:server.directories.logs}/query.log"
11371162
filePattern="${config:server.directories.logs}/query.log.%02i">
@@ -1145,7 +1170,7 @@ To change the format, the layout for the `QueryLogger` must be changed from usin
11451170

11461171
to using the `JsonTemplateLayout`:
11471172

1148-
[source%linenums,xml,options="nowrap",highlight=4]
1173+
[source,xml,options="nowrap",highlight=4]
11491174
----
11501175
<RollingRandomAccessFile name="QueryLog" fileName="${config:server.directories.logs}/query.log"
11511176
filePattern="${config:server.directories.logs}/query.log.%02i">
@@ -1310,7 +1335,7 @@ Additionally, GQL codes for external procedures are not yet stable.
13101335
The following are examples of the `errorInfo` JSON object:
13111336

13121337
.`errorInfo` JSON object of a database error
1313-
[source%linenums,xml,options="nowrap",highlight=4]
1338+
[source,xml,options="nowrap",highlight=4]
13141339
----
13151340
...
13161341
"errorInfo": {
@@ -1327,7 +1352,7 @@ The following are examples of the `errorInfo` JSON object:
13271352
----
13281353

13291354
.`errorInfo` JSON object of a client error
1330-
[source%linenums,xml,options="nowrap",highlight=4]
1355+
[source,xml,options="nowrap",highlight=4]
13311356
----
13321357
...
13331358
"errorInfo": {

0 commit comments

Comments
 (0)