How to logrotate neo4j.log file

The neo4j.log file is a redirection to STDOUT. When you implement a default logrotate strategy, Neo4j will not be able to write to that file anymore after a rotation.

Solution

You can use “copytruncate” in your logrotate configuration file.

Example Logrotate Configuration
/usr/local/neo4j/logs/neo4j.log {
	su neo4j neo4j
	copytruncate
	rotate 4
	daily
	compress
	missingok
	notifempty
}

Note :

There is a very small time slice between copying the file and truncating it, so some logging data might be lost. When this option is used, the create option will have no effect, as the old log file stays in place.

References

  • Logrotate Manual ”’
  • Last Modified: 2020-09-23 21:26:58 UTC by Christophe Willemsen.
  • Relevant for Neo4j Versions: 3.0.
  • Relevant keywords logs.