Show/Hide Toolbars

Running code with logging methods can have an impact on performance. You can prevent code from running unnecessarily by first checking whether the specified logger level is enabled on the Logging page of Admin Settings.

The API provides the following methods for checking whether the Debug or Info logger levels are enabled:

isDebug() to check for the Debug logger level.

isInfo() to check for the Info logger level.

Note: These levels have methods for checking because levels of a higher severity are not intended for code in production.

The following code for logging Debug and Info log messages checks whether the logger levels are turned on before running the log methods.

// Log some debugging information

logDebug("rule executed");

// Check the log level before executing complex debugging statements to improve performance

if(isDebug()) {

logDebug("rule executed by " + username + " at " + time);

}

 

// Log an informational message

logInfo("rule executed");

// Check the log level before executing complex informational statements to improve performance

if(isInfo()) {

logInfo("rule executed by " + username + " at " + time);

}