Knowledge Base
Published Sep. 10, 2025

Changing the Liferay Instance's Log Time Zone Without Modifying the JVM Time Zone

Written By

Liferay Support

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.

Introduction

By default, Liferay's JVM uses the UTC (GMT) timezone for scheluding jobs and displaying the correct dates in the presentation layer. However, you can change the time zone for the log files without modifying this default configuration.

In this article, you'll customize the portal-log4j.xml file within the Liferay_home/logs/ folder to adjust the time zone for your Liferay instance's logs.

IMPORTANT
Please be aware that you shouldn't adjust the time zone at the JVM level to avoid major scheduling issues and incorrect behavior (e.g., incorrect dates in the Calendar page element).

Environment

  • DXP 7.1, 7.2, and 7.3
  • Portal 6

Steps

  1. Go to the [LIFERAY_HOME]/[TOMCAT_HOME]/webapps/ROOT/WEB-INF/lib/portal-impl.jar/META-INF/ folder.
  2. Get a copy of the portal-log4j.xml file by extracting it from the portal-impl.jar file.
  3. Get a copy of the log4j.dtd file from the same location.
    NOTE
    For Liferay DXP 7.2, the log4j.dtd file may not be present in this location. You can safely ignore this step.
  4. Rename your copy of the portal-log4j.xml file to portal-log4j-ext.xml.
    Because the copied file is supposed to override the original properties from the portal-log4j.xml file in the portal-impl.jar, we will only keep the following contents in the portal-log4j-ext.xml file:
    <?xml version="1.0"?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
    		<layout class="org.apache.log4j.EnhancedPatternLayout">
    			<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}:%L] %m%n" />
    		</layout>
    	</appender>
    
    	<appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
    		<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
    			<param name="FileNamePattern" value="@liferay.home@/logs/liferay@spi.id@.%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>
    
    	<root>
    		<priority value="INFO" />
    		<appender-ref ref="CONSOLE" />
    		<appender-ref ref="FILE" />
    	</root>
    </log4j:configuration>
  5. Find the following section:
    <layout class="org.apache.log4j.EnhancedPatternLayout">
    	<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}:%L] %m%n" />
    </layout>

    As you can see from your own portal-log4j-ext.xml file, there are two copies of this section.

    The first section is found inside the <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> </appender> node, and the configurations made to it will be applied on the Console log files.

    The second section is found within the <appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender"></appender> node, and the configurations made to it will be applied on the log files stored in the specified file system location, which in this case is @liferay.home@/logs/liferay.%d{yyyy-MM-dd}.log.

  6. In both sections:
    1. Change <layout class="org.apache.log4j.PatternLayout"> to <layout class="org.apache.log4j.EnhancedPatternLayout">
      NOTE
      For Liferay DXP 7.2, this change may already be made, so it can be skipped.
    2. Change <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}:%L] %m%n" /> to <param name="ConversionPattern" value="%d{ABSOLUTE}{TIMEZONE} %-5p [%t][%c{1}:%L] %m%n" />.
  7. Change the TIMEZONE value to your desired time zone.
    You can find the values at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.

  8. Place the modified portal-log4j-ext.xml file and the log4j.dtd file (if applicable) at [LIFERAY_HOME]/[TOMCAT_HOME]/webapps/ROOT/WEB-INF/lib/portal-impl.jar/META-INF.
  9. Start the portal.

After starting the portal, the initial section of the startup log will still be in GMT (this should still be controlled by the JVM’s time zone settings), but when it gets to the database connection section, the time zone will be the time in the time zone you specified. All the information from the database connection log section will be recorded in your Liferay instance's log file ([LIFERAY_HOME/logs]).

NOTE
The steps above works well for development as the end user can make changes easily, or remove the logging change without having to recompile the ext.

Additional Information

  • If you have already deployed a custom logging file like above, you can add these changes to this file, or it can be included as part of an ext-impl.jar. If you have an existing ext-impl.jar file, make these changes in the ${EXT}/docroot/WEB-INF/ext-impl/src/META-INF location of the source code of the ext file. Then, compile and replace the ext file.
  • Always configure time zones at the instance or user levels. The JVM's default time zone (UTC) should not be changed to avoid job scheduling issues and incorrect behavior. See the Things Liferay Won't Say blog post for more information.
Did this article resolve your issue ?

Knowledge Base