How to rotate Confluence logs overnight and adding date to the filename

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

This article explains how to rotate Confluence Application logs overnight and add the date to the filename configured in the log4j.properties file.

Solution

Confluence uses Apache's log4j logging service. This allows administrators to control the logging behaviour and the log output file.

The logging behaviour for Confluence and Synchrony is defined in the following properties file which is a standard log4j configuration file, as described in the Apache log4j documentation. In our case, this file is located at <CONFLUENCE_INSTALL_HOME>/confluence/WEB-INF/classes/log4j.properties

Customizing Log Rotation

To rotate the log file overnight and add the date to the filename of the logs, the below changes can be done in the log4j.properties file.

In the example below, it is covered how to modify Confluence application logs ( atlassian-confluence.log ). Similarly, the log4j appender can be modified for other log files like Synchrony logs ( atlassian-synchrony.log ), Security( atlassian-confluence-security.log ), Indexing logs( atlassian-confluence-index.log) or any other logs configured.

To achieve this, edit the log4j.properties file as:

1 2 3 4 5 6 7 8 9 10 11 12 #log4j.appender.confluencelog=com.atlassian.confluence.logging.ConfluenceHomeLogAppender # Comment the above line and uncomment the following 2 lines if you want to log to a specific location #log4j.appender.confluencelog=org.apache.log4j.RollingFileAppender log4j.appender.confluencelog.File=[Path_for_logs]/atlassian-confluence.log #log4j.appender.confluencelog.LogFileName=atlassian-confluence.log log4j.appender.confluencelog=org.apache.log4j.DailyRollingFileAppender log4j.appender.confluencelog.DatePattern='.'yyyy-MM-dd log4j.appender.confluencelog.Threshold=DEBUG #log4j.appender.confluencelog.MaxFileSize=20480KB #log4j.appender.confluencelog.MaxBackupIndex=5 log4j.appender.confluencelog.layout=com.atlassian.confluence.util.PatternLayoutWithContext log4j.appender.confluencelog.layout.ConversionPattern=%d %p [%t] [%c{4}] %M %enc{%m}{JSON}%n

DatePattern

In the above code, DailyRollingFileAppender is a log4j appender which will rotate the file daily on the basis of the DatePattern configured.

Below are some of the possible DatePatterns in log4j which can be configured to roll log files accordingly:

Date Pattern

Rolling Schedule

'.'yyyy-MM

Rollover at the beginning of each month

'.'yyyy-ww

Rollover on the first day of each week. The first day of the week depends on the locale.

'.'yyyy-MM-dd

Rollover at midnight each day.

'.'yyyy-MM-dd-a

Rollover at midnight and midday of each day.

'.'yyyy-MM-dd-HH

Rollover at the top of every hour.

'.'yyyy-MM-dd-HH-mm

Rollover at the beginning of every minute.

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.