Legacy Knowledge Base
Published Sep. 10, 2025

Logs Rotation

Written By

Ankit Gupta

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

If you want to rotate logs for every 12 hours in a day(2 log files to be created each day)

Environment

  • Liferay 6.2

Resolution

The logs can be rotated for every 12 hours and it can be achieved through a very slight change in portal-log4j.xml. This file can be found in \webapps\ROOT\WEB-INF\lib\portal-impl.jar\META-INF\. Also, to make changes in the default file, it is suggested to create a portal-log4j-ext.xml and insert the desired changes there, to avoid making a permanent change to the original file and place it in this location ${TOMCAT_HOME}/webapps/ROOT/WEB-INF/classes/META-INF.

<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
            <param name="FileNamePattern" value="@liferay.home@/logs/liferay@spi.id@.%d{yyyy-MM-dd-a}.log" />
</rollingPolicy>

Please Note:
Just append yyyy-MM-dd.log with a, i.e. it should look like yyyy-MM-dd-a.log. This would split the logs every 12 hours and would append AM or PM in the log file name. Which means the log file for a day would split into 2 parts, for 12 hours each and would split at 12 AM or PM.

Additional Information

  • This link might help to understand that in how many different ways it is possible to rotate logs.
  • This resolution requires customization and should only be implemented at the discretion of your team. Liferay Support will not be able to assist with designing or implementing customizations.
Did this article resolve your issue ?

Legacy Knowledge Base