Legacy Knowledge Base
Published Sep. 10, 2025

Logs rotation based on size in Liferay DXP 7.4

Written By

Koustuv Dhani

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

  • Configuring log rotation for logs based on the size.

Environment

  • Liferay DXP 7.4

Resolution

  • The logs can be rotated based on size by making a small adjustment in the portal-log4j.xml file.
  • Extract portal-impl.jar from /tomcat-9.0.73/webapps/ROOT/WEB-INF/shielded-container-lib/ and copy the portal-log4j.xml file. Then, paste portal-log4j.xml into ${TOMCAT_HOME}/webapps/ROOT/WEB-INF/classes/META-INF and rename it to portal-log4j-ext.xml.
  • Modify both <Appender> blocks for .log and .xml in portal-log4j-ext.xml to enable log rotation based on size. Following is the sample configuration for reference:
    <Appender name="TEXT_FILE" type="RollingFile"
    fileName="@liferay.home@/logs/liferay.log"
    filePattern="@liferay.home@/logs/liferay.%d{yyyy-MM-dd}-%i.log.gz"
    ignoreExceptions="false">
    <Layout type="PatternLayout" pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p [%t][%c{1}:%L] %m%n" />
    <Policies>
    <SizeBasedTriggeringPolicy size="10KB"/>
    </Policies>
    <DefaultRolloverStrategy max="30"/>
    </Appender>

    <Appender name="XML_FILE" type="RollingFile"
    fileName="@liferay.home@/logs/liferay.xml"
    filePattern="@liferay.home@/logs/liferay.%d{yyyy-MM-dd}-%i.xml.gz"
    ignoreExceptions="false">
    <Log4j1XmlLayout locationInfo="true" />
    <Policies>
    <SizeBasedTriggeringPolicy size="10KB"/>
    </Policies>
    <DefaultRolloverStrategy max="30"/>
    </Appender>
  • Note: The file is rolled over after reaching a specified size of 10KB, creating a maximum of 30 log files. Initially, the log file is named liferay.log. Once it reaches 10KB, it is renamed to liferay.2024-08-22-1.log.gz.

Additional Information

Did this article resolve your issue ?

Legacy Knowledge Base