This article demonstrates how to create a separate audit.YYYY-MM-DD.log file within ${liferay.home}/log
for audit INFO messages. It should roll over every day with this configuration.
Environment
- Liferay Portal EE 6.1 & 6.2
Resolution
Procedure in Liferay Portal 6.1 and 6.2
- Make sure the Liferay Audit portlet is successfully deployed from Liferay Marketplace.
- Within
${tomcat.home}/webapps/audit-portlet/WEB-INF/classes/META-INF/audit-spring.xml
verify thatcom.liferay.portal.audit.LogAuditRouterProcessor
bean is already enabled.<property name="globalAuditMessageProcessors"> <list value-type="com.liferay.portal.kernel.audit.AuditMessageProcessor"> <ref bean="com.liferay.portal.audit.DatabaseAuditRouterProcessor" /> <ref bean="com.liferay.portal.audit.LogAuditRouterProcessor" /> </list> </property>
- Extract both
log4j.dtd
from${tomcat.home}/webapps/ROOT/WEB-INF/lib/portal-impl.jar
into${tomcat.home}/webapps/ROOT/WEB-INF/classes/META-INF
- Create
portal-log4j-ext.xml
and place it into${tomcat.home}/webapps/ROOT/WEB-INF/classes/META-INF
- Add the following information into
portal-log4j-ext.xml
<?xml version="1.0"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- additional audit logging -->
<appender name="auditFile" class="org.apache.log4j.rolling.RollingFileAppender"> <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"> <param name="FileNamePattern" value="@liferay.home@/logs/audit.%d{yyyy-MM-dd}.log" /> </rollingPolicy> <layout class="org.apache.log4j.EnhancedPatternLayout"> <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}:%L] %m%n" /> </layout> </appender>
<category name="com.liferay.portal.audit.LogAuditRouterProcessor"> <priority value="INFO" /> <appender-ref ref="auditFile"/> </category>
</log4j:configuration>
- Restart the server and verify that the audit log file is created within
${liferay.home}/logs