Saturday, May 25, 2024

Logging Messages in Pega Using Data Transforms

Pega offers a set of out-of-the-box (OOTB) functions to log messages at different levels in the Pega logs. This can be incredibly useful for debugging and monitoring the behavior of your applications. In this post, we'll explore how to log messages through Data Transforms in Pega, specifying the desired log level.

Available Logging Functions

Pega provides two main functions that you can use in Data Transforms to log messages:

  1. @Default.pxLogMessage(sMessage): Logs the message at the error level.
  2. @Default.pxLogMessage(sMessage, cLevel): Logs the message at a specified level.

Parameters:

  • sMessage: The message you want to log.
  • cLevel: The log level, indicated by a single character:
    • d – debug
    • i – info
    • f – info forced
    • w – warn
    • e – error

Viewing Log Messages

To view the log messages in Pega Dev Studio, navigate to:


Dev Studio > Configure > System > Operations > Logs > Log files > PegaRULES.Log

Example Usage

Let's look at how to log a message as info forced and error using Data Transforms.

Log a Message as InfoForced

To log a message as info forced, use the following syntax in your Data Transform:


@(Pega-RULES:Default).pxLogMessage(param.Message, 'f')

Log a Message as Error

To log a message as error, use the following syntax in your Data Transform:


@(Pega-RULES:Default).pxLogMessage(param.Message, 'e')

Conclusion

Using these OOTB functions to log messages at different levels in Pega is straightforward and powerful for tracking the behavior and issues in your application. Happy logging!


Featured post

Queue Processor

  Overview Starting with Pega Platform version 8.1, Job Scheduler and Queue Processor rules replace Agents and improve background processi...

Popular Posts