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:
@Default.pxLogMessage(sMessage)
: Logs the message at the error level.@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
– debugi
– infof
– info forcedw
– warne
– 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!
No comments:
Post a Comment