This content has been archived.
Close popover

Pega Platform logging with the Log4j 2 logging service

As of Pega® 7.3, the Apache Log4j 1 logging service has been upgraded to the Apache Log4j 2 logging service. The prlogging.xml file has been replaced with the prlog4j2.xml file. Apache Log4j 2 improves performance and provides support for all log file appender types.

The prlog4j2.xml file contains the configuration settings for logging. When Pega Platform is started, it looks for a user-specific file, for example, custom-prlog4j2.xml. If Pega Platform does not find a user-specific file, it looks for the default prlog4j2.xml logging configuration file. When a configuration file is found, it is used to configure and initialize Log4j 2. The default prlog4j2.xml file includes the following appenders:

  • CONSOLE– Prints all log messages, except alerts, to the console.
  • PEGA – Prints all log messages, except alerts, to a file.
  • ALERTSECURITY – Prints security alerts to a file.
  • ALERT – Prints performance alerts to a file.
  • BIX - Prints Business Intelligence Exchange alerts to a file.
  • SECURITYEVENT - Prints security event alerts to a file.
  • CLUSTER - Prints alerts about the setup and run-time behavior of the cluster to a file.

Apache Log4j 2 includes additional appenders that you can add to the prlog4j2.xml file. For more information, see the Apache Log4j 2 documentation on the Apache logging services website.

Rollover policy

The rollover policy for log files is based on time (daily) and file size (the maximum file size is 250 MB). Files are rolled over daily or when the maximum file size is reached.

Current (not rolled over) log files do not have a time stamp. The time stamp is added when the log is rolled over. You can add the date to the current log file; however, the log file will not be rolled over. To add the date, configure the file name as follows:

fileName="${sys:pega.logdir}/PegaRULES-${date:yyyy-MM-dd}.log

For example:

<RollingRandomAccessFile name="PEGA" fileName="${sys:pega.logdir}/PegaRULES-${date:yyyy-MM-dd}.log" filePattern="${sys:pega.logdir}/PegaRULES-%d{MM-dd-yyyy}-%i.log.gz">

The server start date is added to the file name, not the rollover date.

If you use an Eclipse-embedded Apache Tomcat server, the default log file location is /miniboot-embedded/New_configuration/Tomcat/work folder. If you use a stand-alone Tomcat server, the default log file location is \apache-tomcat-8.0.32\work\Catalina\localhost\prweb. You can change the location of the log files by setting the pega.logdir variable.

Default prlog4j2.xml file

The following is an example of the default prlog4j2.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>

<Console name="CONSOLE" target="SYSTEM_OUT">
<PatternLayout pattern="%d [%20.20t] [%10.10X{pegathread}] [%20.20X{tenantid}] [%20.20X{app}] (%30.30c{3}) %-5p %X{stack} %X{userid} - %m%n"/>
<Filters>
<!--Deny message logged under ALERT log level-->
<ThresholdFilter level="ALERT" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>
</Console>

<RollingRandomAccessFile name="PEGA" fileName="${sys:pega.logdir}/PegaRULES.log" filePattern="${sys:pega.logdir}/PegaRULES-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>%d [%20.20t] [%10.10X{pegathread}] [%20.20X{tenantid}] [%20.20X{app}] (%30.30c{3}) %-5p %X{stack} %X{userid} - %m%n</Pattern>
</PatternLayout>
<Filters>
<!--Deny message logged under ALERT log level-->
<ThresholdFilter level="ALERT" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingRandomAccessFile>

<!-- RollingRandomAccessFile Appender for pegarules PERFORMANCE Alert logs -->
<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>%m%n</Pattern>
</PatternLayout>
<ThreadContextMapFilter onMatch="DENY" onMismatch="NEUTRAL" operator="or">
<KeyValuePair key="alertType" value="security"/>
</ThreadContextMapFilter>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingRandomAccessFile>

<!-- RollingRandomAccessFile Appender for PegaRULES-ALERTSECURITY logs -->
<RollingRandomAccessFile name="ALERTSECURITY" fileName="${sys:pega.logdir}/PegaRULES-ALERTSECURITY.log" filePattern="${sys:pega.logdir}/PegaRULES-ALERTSECURITY-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>%m%n</Pattern>
</PatternLayout>
<ThreadContextMapFilter onMatch="ACCEPT" onMismatch="DENY" operator="or">
<KeyValuePair key="alertType" value="security"/>
</ThreadContextMapFilter>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingRandomAccessFile>

<!-- RollingRandomAccessFile Appender for PegaBIX logs logs -->
<RollingRandomAccessFile name="BIX" fileName="${sys:pega.logdir}/PegaBIX.log" filePattern="${sys:pega.logdir}/PegaBIX-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>%d [%20.20t] [%20.20X{tenantid}] [%20.20X{app}] (%30.30c{3}) %-5p %X{stack} %X{userid} - %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingRandomAccessFile >

<!-- RollingRandomAccessFile Appender for PegaRULES-SecurityEvent logs -->
<RollingRandomAccessFile name="SECURITYEVENT" fileName="${sys:pega.logdir}/PegaRULES-SecurityEvent.log" filePattern="${sys:pega.logdir}/PegaRULES-SecurityEvent-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>%m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
</RollingRandomAccessFile >

<!-- RollingRandomAccessFile Appender for PegaCLUSTER logs -->
<RollingRandomAccessFile name="CLUSTER" fileName="${sys:pega.logdir}/PegaCLUSTER.log" filePattern="${sys:pega.logdir}/PegaCLUSTER-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout>
<Pattern>%d [%20.20t] [%20.20X{tenantid}] [%20.20X{app}] (%30.30c{3}) %-5p %X{stack} %X{userid} - %m%n</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="50 MB"/>
</Policies>
</RollingRandomAccessFile >

</Appenders>

<Loggers>
<asyncRoot>
<AppenderRef ref="CONSOLE"/>
<AppenderRef ref="PEGA"/>
<AppenderRef ref="ALERT" level="ALERT"/>
<AppenderRef ref="ALERTSECURITY" level="ALERT"/>
</asyncRoot>
<Logger name="com.pega.pegarules.session.internal.mgmt.SecurityEventLogger" additivity="false" level="info">
<AppenderRef ref="SECURITYEVENT"/>
</Logger>
<Logger name="com.pega.pegarules.data.internal.access.ExtractImpl" additivity="false" level="info">
<AppenderRef ref="BIX"/>
</Logger>
<Logger name="com.pega.pegarules.data.internal.access.ExtractParameters" additivity="false" level="info">
<AppenderRef ref="BIX"/>
</Logger>
<Logger name="com.pega.pegarules.data.internal.access.DatabaseUtilsCommonImpl" additivity="false" level="info">
<AppenderRef ref="BIX"/>
</Logger>
<Logger name="com.hazelcast" additivity="false" level="info">
<AppenderRef ref="CLUSTER"/>
</Logger>
<Logger name="org.apache.ignite" additivity="false" level="info">
<AppenderRef ref="CLUSTER"/>
</Logger>
</Loggers>

</Configuration>


37% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.