Question
Pegasystems Inc.
JP
Last activity: 29 Oct 2018 20:18 EDT
Is it possible to change log timezone for ALERT, ALERTSECURITY and SecurityEvent log?
We can change log timezone for PegaRULES.log by changing prlogging.xml or set application server's timezone (reference: Changing PRPC log timezone from GMT to JST)
But Pega7 outputs date in message for following log files - ALERT, ALERTSECURITY and SecurityEvent log, and the timezone is GMT. (The pattern is defined as %m%n in prlog4j2.xml)
Is there any way to change the time in the log message?
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
US
Yes, for PegaRULES-ALERT.log, PegaRULES-ALERTSECURITY.log, and PegaRULES-SecurityEvent.log, the date and time are hardcoded in the messages.
Vodafone
IN
Hello Mashashi,
Thanks for your time on posting your query on PSC :)
Assuming your server is on Tokyo time zone, Modify the below changes to convert your alert/alertSecurity logs to Tokyo time zone.
1. If you are using Tomcat server >> Go to bin>>setenv bat file add the below code.
CATALINA_OPTS='-Duser.timezone=Asia/Tokyo'
export CATALINA_OPTS
2. Go to>> webapps>.prweb>>WEB-INF>>classes>>prlogging.xml
Change the below code:
Before change:
After Change:
Hello Mashashi,
Thanks for your time on posting your query on PSC :)
Assuming your server is on Tokyo time zone, Modify the below changes to convert your alert/alertSecurity logs to Tokyo time zone.
1. If you are using Tomcat server >> Go to bin>>setenv bat file add the below code.
CATALINA_OPTS='-Duser.timezone=Asia/Tokyo'
export CATALINA_OPTS
2. Go to>> webapps>.prweb>>WEB-INF>>classes>>prlogging.xml
Change the below code:
Before change:
After Change:
Request to do the same for alertSecurity logs too if needed.
Let me know if you have any queries regarding this.
Regards,
Naveen
Pegasystems Inc.
JP
Hi Naveen,
Thanks for your advice. I understand that your I can add the date in local timezone, but it doesn't replace existing one. For example, when I update prlog4j2.xml (I'm using Pega 7.4) as follows.
<RollingRandomAccessFile name="ALERT" fileName="${sys:pega.logdir}/PegaRULES-ALERT.log" filePattern="${sys:pega.logdir}/PegaRULES-ALERT-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>%d %m%n</Pattern><!-- added %d before %m%n -->
</PatternLayout>
<ThreadContextMapFilter onMatch="DENY" onMismatch="NEUTRAL" operator="or">
<KeyValuePair key="alertType" value="security"/>
</ThreadContextMapFilter>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingRandomAccessFile>
The ALERT log output like this.
Hi Naveen,
Thanks for your advice. I understand that your I can add the date in local timezone, but it doesn't replace existing one. For example, when I update prlog4j2.xml (I'm using Pega 7.4) as follows.
<RollingRandomAccessFile name="ALERT" fileName="${sys:pega.logdir}/PegaRULES-ALERT.log" filePattern="${sys:pega.logdir}/PegaRULES-ALERT-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>%d %m%n</Pattern><!-- added %d before %m%n -->
</PatternLayout>
<ThreadContextMapFilter onMatch="DENY" onMismatch="NEUTRAL" operator="or">
<KeyValuePair key="alertType" value="security"/>
</ThreadContextMapFilter>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingRandomAccessFile>
The ALERT log output like this.
2018-08-27 15:36:20,231 2018-08-27 06:36:20,221 GMT*8*PEGA0005*1047*500*8d3dfbbcbe7edb849a519edc9976cfa9*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,047 ms SQL: select pzPVStream from rules.pr4_base where pxObjClass = ?*
You can see both local time and GMT, because ALERT log message string contains GMT time. If it's the only way to configure date, we cannot change the date IN message string. Am I correct?
Vodafone
IN
Hello,
That will show both the dates, In my case too I found 2 dates (local and GMT).
Regards,
Naveen
Pegasystems Inc.
US
Hello Masashi,
It is possible to have the date written in the timezone of our choice, and only have the date appears once per log message. Assuming Pega Platform 7.3 or higher, you need to change the relevant Pattern or PatternLayout elements in the Log4j configuration file prlog4j2.xml. This file is bundled within the Pega Platform WAR and EAR files. You can see a sample of this file in the following article in the Pega Community: https://community.pega.com/knowledgebase/articles/pega-platform-logging-log4j-2-logging-service.
For example, one of the PatternLayout within the prlog4j2.xml file (in my Pega Platform 8.1 instance) looks like this:
<PatternLayout pattern="%d [%20.20t] [%10.10X{pegathread}] [%20.20X{tenantid}] [%20.20X{app}] (%30.30c{3}) %-5p %X{stack} %X{userid} - %m%n"/>
To update this PatternLayout to display the date and time as per the timezone Asia/Tokyo, you simply update it as below:
Hello Masashi,
It is possible to have the date written in the timezone of our choice, and only have the date appears once per log message. Assuming Pega Platform 7.3 or higher, you need to change the relevant Pattern or PatternLayout elements in the Log4j configuration file prlog4j2.xml. This file is bundled within the Pega Platform WAR and EAR files. You can see a sample of this file in the following article in the Pega Community: https://community.pega.com/knowledgebase/articles/pega-platform-logging-log4j-2-logging-service.
For example, one of the PatternLayout within the prlog4j2.xml file (in my Pega Platform 8.1 instance) looks like this:
<PatternLayout pattern="%d [%20.20t] [%10.10X{pegathread}] [%20.20X{tenantid}] [%20.20X{app}] (%30.30c{3}) %-5p %X{stack} %X{userid} - %m%n"/>
To update this PatternLayout to display the date and time as per the timezone Asia/Tokyo, you simply update it as below:
<PatternLayout pattern="%d{DEFAULT}{Asia/Tokyo} [%20.20t] [%10.10X{pegathread}] [%20.20X{tenantid}] [%20.20X{app}] (%30.30c{3}) %-5p %X{stack} %X{userid} - %m%n"/>
Remark: Pega Platform displays the date and time using the default format for the system, and it is what I specify in the PatternLayout above. More to the point, if you do not specify the date and time format, the timezone setting is ignored. There are many date and time formats supported and you can read more about them in the Log4j documentation here: https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout. Look for the section Patterns and the table that list the Conversion Pattern.
I hope this helps.
Alan
Pegasystems Inc.
JP
Hi Alan,
Thank you for comments. But the thing is, the date is output in the message (%m) for these logs, so it appears 2 times in your example - at the beginning of the line and after the userid.
Regards,
Accepted Solution
Pegasystems Inc.
US
Yes, for PegaRULES-ALERT.log, PegaRULES-ALERTSECURITY.log, and PegaRULES-SecurityEvent.log, the date and time are hardcoded in the messages.
CollabPartnerz
IN
Please find the below link might help you
https://collaborate.pega.com/question/which-best-tool-analyze-pega-rules-and-alerts-log
-
Bachir Amazigh BADJADJ
Pegasystems Inc.
PL
Did you try to check above suggestion? Is it working as it should?
Pegasystems Inc.
JP
The above link is about analyzing log (with PLA or AES/PDC), not to modify the log message (time is output in message itself) of ALERT, ALERTSECURITY and SecurityEvent log. Modifying prlog4j2.xml appends date time, but that doesn't mean change time format in the message (as I commented above.) It doesn't work as I wanted to do.
Pegasystems Inc.
JP
As commented above, should I think there is no way to configure local time on existing log message in ALERT, ALERTSECURITY and SecurityEvent log?
-
Andy Wong SAIRAJESH NADIPINENI
CollabPartnerz
IN
Please find the below link might help you
https://collaborate.pega.com/question/which-best-tool-analyze-pega-rules-and-alerts-log
Pegasystems Inc.
JP
Thank you, but that link doesn't help. The discussion is about how to analyze the log, that's not about how to configure OOTB log message.