Logging Trigger Scripts
To assist in debugging trigger scripts, you can write from a trigger script to the server.log file. The output data from the trigger script may indicate where the problem is.
To print to the log file, use the following syntax:
Packages.mks.util.Logger.message("Category", level, "Text");
where
• Category - the logging category.
• Level - the logging level.
• Text - the text to be written out to the server log file.
for example:
Packages.mks.util.Logger.message( "DEBUG", 5, "Debug message!" );
Decide if you want to use the default DEBUG logging category, a custom category for each trigger script, or a custom category for all trigger scripts.
To print to the server log, PTC recommends using a JavaScript function, for example:
function print(msg, level) {
if (level == null) level = 5;
Packages.mks.util.Logger.message("MYTRIGGER", level, msg);
}
If you use a custom category, you need to update the logger.properties file with the new category, for example:
mksis.logger.message.includeCategory.MYTRIGGER=10