3.8. Transaction logs

This section explains the retention and rotation policies for the Neo4j transaction logs, and how to configure them.

The transaction logs record all operations in the database. They are the "source of truth" in scenarios where the database needs to be recovered. Transaction logs are used to provide for incremental backups, as well as for cluster operations. For any given configuration, at least the latest non-empty transaction log will be kept.

Log rotation
Log rotation is configured using the parameter dbms.tx_log.rotation.size. By default, log switches happen when log sizes surpass 250 MB.
Amount of transactions retained

There are several different means of controlling the amount of transaction logs that are kept, using the parameter dbms.tx_log.rotation.retention_policy. This parameter can be configured in two different ways:

  • dbms.tx_log.rotation.retention_policy=<true/false>, or
  • dbms.tx_log.rotation.retention_policy=<amount> <type>

Transaction log pruning refers to the safe and automatic removal of old, unnecessary transaction log files. The transaction log can be pruned when one or more files fall outside of the configured retention policy. Two things are necessary for a file to be removed:

  • The file must have been rotated.
  • At least one checkpoint must have happened in a more recent log file.

Observing that you have more transaction log files than you expected is likely due to checkpoints either not happening frequently enough, or taking too long. This is a temporary condition and the gap between expected and observed number of log files will be closed on the next successful checkpoint. The interval between checkpoints can be configured using dbms.checkpoint.interval.time and dbms.checkpoint.interval.tx. If your goal is to have the least amount of transaction log data, it can also help to speed up the checkpoint process itself. The configuration parameter dbms.checkpoint.iops.limit controls the number of IOs per second the checkpoint process is allowed to use. Setting the value of this parameter to -1 allows unlimited IOPS, which can speed up checkpointing. Note that disabling the IOPS limit can cause transaction processing to slow down a bit.

Table 3.6. Types that can be used to control log retention
Type Description Example


Number of most recent logical log files to keep

"10 files"


Max disk size to allow log files to occupy

"300M size" or "1G size"


Number of transactions to keep

"250k txs" or "5M txs"


Keep logs which contains any transaction committed within N hours from current time

"10 hours"


Keep logs which contains any transaction committed within N days from current time

"50 days"

Example 3.8. Configure log retention policy

This example shows some different ways to configure the log retention policy.

  • Keep logical logs indefinitely:

  • Keep only the most recent non-empty log:

  • Keep logical logs which contain any transaction committed within 30 days:

    dbms.tx_log.rotation.retention_policy=30 days
  • Keep logical logs which contain any of the most recent 500 000 transactions:

    dbms.tx_log.rotation.retention_policy=500k txs