I'm facing an issue while trying to customise Log rolling strategy in Liferay DXP.
In portal-log4j-ext.xml
file , I wanted to :
- Create rolling log strategy base on max file size and with the date appended in the end of file name.
- Create a Daily rolling log strategy that create the daily log file with compression.
Above the portal-log4j-ext.xml :
<appender name="PROJECT" class="org.apache.log4j.RollingFileAppender">
<!-- The active file to log to -->
<param name="file" value="@liferay.home@/logs/logging/liferay@spi.id@.%d.log" />
<param name="MaxFileSize" value="5KB"/>
<param name="MaxBackupIndex" value="100"/>
<param name="append" value="true" />
<param name="encoding" value="UTF-8" />
<!-- Keep one backup file -->
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern" value="@liferay.home@/logs/logging/archive/liferay@spi.id@.%d.log.gz" />
</rollingPolicy>
<layout class="org.apache.log4j.EnhancedPatternLayout">
<param name="ConversionPattern" value="[%d{dd.MM.yyyy HH:mm:ss}{Europe/Paris}] %-5p [%t][%c{1}:%L] %m%n" />
</layout>
</appender>
<root>
<priority value="INFO" />
<appender-ref ref="PROJECT" />
<!--appender-ref ref="CONSOLE" /-->
<!--appender-ref ref="XML_FILE" /-->
<!--<appender-ref ref="TEXT_FILE" />-->
</root>
Here the generated file logs:
The problem is that the date is not appended to generated files, and TimeBasedRollingPolicy is not working.
I'm using Log4j 1.2
Do you have any suggestion?
Thanks in advance.