Legacy Knowledge Base
Published Jul. 2, 2025

Configuring Log4j Logging for the Audit Portlet in Liferay Portal EE

Written By

Brian Larson

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.

This article demonstrates how to create a separate audit.YYYY-MM-DD.log file within ${liferay.home}/logfor audit INFO messages. It should roll over every day with this configuration. 

Environment

  • Liferay Portal EE 6.1 & 6.2

Resolution

Please note: For the following procedures we will use a Liferay Tomcat bundle. Be sure to make the proper adjustments specific to the application server in use.

Procedure in Liferay Portal 6.1 and 6.2 

  1. Make sure the Liferay Audit portlet is successfully deployed from Liferay Marketplace.
  2. Within ${tomcat.home}/webapps/audit-portlet/WEB-INF/classes/META-INF/audit-spring.xml verify that com.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>
    
  3. 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
  4. Create portal-log4j-ext.xml and place it into ${tomcat.home}/webapps/ROOT/WEB-INF/classes/META-INF
  5. 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>
  6. Restart the server and verify that the audit log file is created within ${liferay.home}/logs

 

Did this article resolve your issue ?

Legacy Knowledge Base