Legacy Knowledge Base
Published Sep. 10, 2025

Logs rotation based on size

Written By

Sivakumar Perumal

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

  • How to implement the log rotation for Liferay logs based on the size

Environment

  • Liferay Portal 6.2
  • Liferay DXP 7.0

Resolution

  • The logs can be rotated based on the size 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.

    log4j.appender.DAILY=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.DAILY.File=/logs/liferay.log
    log4j.appender.DAILY.DatePattern='.'yyyy-MM-dd
    log4j.appender.DAILY.layout=org.apache.log4j.PatternLayout
    log4j.appender.DAILY.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %c:%L - %m%n
    log4j.appender.DAILY.MaxFileSize=100KB
    log4j.appender.DAILY.MaxBackupIndex=5

    Note: The file is rolled over after a specified size has been reached. i.e. This log4j.properties file will create a log file named liferay.log in the folder /logs. If this file exceeds a size of 100KB, it will be renamed to liferay.log.1 and replaced by a new liferay.log file. A maximum of 5 such backup files will be created. To configure max file size in megabytes, use MB as in 20MB. Please reach out to the Liferay Global Services team for further help.

Additional Information

Did this article resolve your issue ?

Legacy Knowledge Base