Tuesday, April 9, 2019

Logging in Pega PRPC

Logging in Pega PRPC:
Logging is an important component of the software development. 
A well-written logging code offers quick debugging, easy maintenance, and structured storage of an application's runtime information.

By default pega had configured Log4J for logging.

Details about the components is explained in PDN link:
https://community.pega.com/knowledgebase/articles/log-customization-prloggingxml-file#capture

Log4j artchitecture you can read it from the below URL:
https://www.tutorialspoint.com/log4j/log4j_quick_guide.htm

More details of the prlogging.xml structure is well explained in the apache site
https://logging.apache.org/log4j/2.x/manual/configuration.html

In logging, all the objects are segregated into two major Object Types:

Core Objects: Mandatory Objects of the framework. composed of objects like Logger Object, Layout Object, Appender Object.

Support Objects: Optional Objects of the framework, but yet do important tasks. This is composed of objects as Level, Filter, ObjectRenderer, LogManager.

In this post we will see how we can customize For Pattern Objects:
Sample Example from Pega prlogging.xml file given below:

<Pattern>%d [%20.20t] [%10.10X{pegathread}] [%20.20X{tenantid}] [%20.20X{app}] (%30.30c{3}) %-5p %X{stack} %X{userid} - %m%n</Pattern>


this is the current logging pattern, we will change this as 

%-6r [%t] %L %-5p %c %x - %m%n

r - meant for elapsed time
t - for thread where its logging
p-priority(info, warn, debug, etc)
c-full class name from where logging is happening
m-message
n-to enter new line

With the above format if we restart the server, to check the new format in pega log.

14752  [localhost-startStop-1]  %I  INFO  com.pega.pegarules.generation.internal.PRGenProviderImpl [] - invokeDynamic instrumentation for inlining is enabled
14752  [localhost-startStop-1]  %I  INFO  com.pega.pegarules.generation.internal.PRGenProviderImpl [] - Assembly Version: 762781845

Set of available logging parameter references are given in the below links, we can do play around to see how its used. some default logging parameters some are overridden for pega.
https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html



1 comment: