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.