How to change the timezone of the application log timestamp
I had like to set it to JST (UTC + 9). We have set two things to achieve this.
- I set the OS time zone to JST
- I set -Duser.timezone = Asia/Tokyo to CATALINA_OPTS
- Changed database timezone to Asia / Tokyo
I confirmed that the above settings are reflected.
I had like to set it to JST (UTC + 9). We have set two things to achieve this.
- I set the OS time zone to JST
- I set -Duser.timezone = Asia/Tokyo to CATALINA_OPTS
- Changed database timezone to Asia / Tokyo
I confirmed that the above settings are reflected.
pegauser@arc-pega-web-686df7dcc4-6gjng:/$ date
Fri Mar 25 20:34:34 JST 2022
pegauser@arc-pega-web-686df7dcc4-6gjng:/$ ps -ef | grep "Duser.timezone=Asia/Toky[o]"
pegauser 1 0 12 20:04 ? 00:03:49 /opt/java/openjdk/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Xms4096m -Xmx16374m -Dhttps.proxyHost=iks-dsp-access-cf0d4249dff268cb3247f5da423f2c3e-i001.jp-tok.containers.appdomain.cloud -Dhttps.proxyPort=1027 -Djava.awt.headless=true -Djava.security.properties=/usr/local/tomcat/conf/java.security.overwrite -DNodeTier=web -XX:HeapDumpPath=/heapdumps -Dpega.logdir=/usr/local/tomcat/logs/arc-pega-web-686df7dcc4-6gjng -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -XX:+UseStringDeduplication -Duser.timezone=Asia/Tokyo -DmaxThreads=300 -Didentification.nodeid=arc-pega-web-686df7dcc4-6gjng -DNodeType=WebUser -DNodeSettings=Pega-IntegrationEngine/EnableRequestorPools=false; -Dindex.directory= -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9001 -Dcom.sun.management.jmxremote.rmi.port=9001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -XX:+DisableExplicitGC -Djava.security.egd=file:///dev/urandom -XX:+ExitOnOutOfMemoryError -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
pega=> show timezone;
TimeZone
------------
Asia/Tokyo
(1 行)
At this point, it has been confirmed that the time zone of the time stamp attached by the log4j logger is JST.
The main subject is from here. The following logs include a time stamp in the Pega application log.
$CATALINA_HOME/logs/pega/PegaRULES-ALERT.log
To clarify the problem, I added a time stamp to the beginning of the format separately on the log4j side .
- log4j config file: $CATALINA_HOME/webapps/prweb/WEB-INF/classes/prlog4j2.xml
- PegaRULES-ALERT.log format: %d{ISO8601}{GMT+9} %m%n
I tried to output the log in this state. Below is the result
pegauser@arc-pega-web-686df7dcc4-mtxqn:/$ head -n 1 $CATALINA_HOME/logs/pega/PegaRULES-ALERT.log
2022-03-25T20:06:03,392 2022-03-25 11:06:03,314 GMT*8*PEGA0005*1663*500*NA*NA*NA*NA*NA*NA*NA*NA*?*-1**0*NA*NA*com.pega.pegarules.data.internal.store.DataStorePreparedStatement*NA*NA*NA*NA*NA****NA*NA*NA*NA*NA*NA*NA*NA*Database query took more than the threshold of 500 ms: 1,663 ms SQL: select pzPVStream from rules.pr4_base where pxObjClass = ?*
Unfortunately, the log added by log4j is JST(UTC +9), but the application log is still UTC + 0....
This Pega is running in a container on an Openshift cluster. The version will be 8.5.2
Best regards