Enabling GC Logging

What is Garbage collection and why enabling it?

A garbage collection event is a complete pause of the java application (ie: neo4j-server).

It can be identified in the debug.log as a stop-the-world event.

For example:

If you notice issues with them such as too many pauses, too long of a pause, pauses causing cluster re-election, etc, you can enabling GC logging for easier integration with monitoring parsers.

Keep in mind the following regarding GC logging:

  • GC log files are cleared out when the database is restarted
  • They are crucial for the analysis of the Application Performance
  • It will add minor overhead
  • You might consider enabling this option on your live environments

Enabling GC logging

As indicated in the product documentation in 3.5 or newer, you can uncomment the following line to enable it:

#dbms.logs.gc.enabled=true

Save the file and restart your server.

GC log location

The log file will be written to the logs directory as specified here and named gc.log.<#>

Additional options

You can review our operational manual (3.5 or newer) for additional settings such as the number of rotated files or their size.

dbms.gc.log.options changes

dbms.gc.log.options differs due to the upgrade from Java 8 to 11 in 4.0.x.

We recommend to leave this commented so neo4j starts with working settings in both versions.

You can review those differences in the table below.

Table 1. Differences between 3.5.x and 4.0.x

neo4j version

configuration value

3.5.x

#dbms.logs.gc.options=-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+PrintTenuringDistribution

4.0.x

#dbms.logs.gc.options=-Xlog:gc*,safepoint,age*=trace