How To
ForgeRock Identity Platform
Does not apply to Identity Cloud

How do I add logging to JavaScript files in IDM (All versions)?

Last updated Apr 8, 2021

The purpose of this article is to provide information on adding logging to JavaScript® files in IDM. You may want to add logging to troubleshoot a script that is not behaving as expected or desired.

2 readers recommend this article

Background information

JavaScript in IDM uses the SLF4J logging facility. By default, the logger outputs logging to the standard IDM log.

There are five different logger levels available for JavaScript files, where ERROR is the least verbose as it only produces logs in the most serious circumstances through to TRACE, which is the most verbose as it provides detailed information about program execution.

These loggers take the following format:

logger.error(string message, optional params) logger.warn(string message, optional params) message, optional params) logger.debug(string message, optional params) logger.trace(string message, optional params)

These five logger levels correspond to the log levels in the file (located in the /path/to/idm/conf directory) as follows:


Specifying logging levels

Within, you can set different logging levels, which affect how logging is output in JavaScript files.

Global logging level

This logging level applies to everything, including JavaScript files and defaults to INFO:


All JavaScript files logging level

This logging level applies to all JavaScript files and overrides the global logging level when set. The property used for setting the log level varies by version:

  • IDM 5.5 and later: org.forgerock.openidm.script.javascript.JavaScript.level
  • IDM 5: org.forgerock.script.javascript.JavaScript.level

Individual JavaScript files logging level 

This logging level applies to specific JavaScript files and overrides the All JavaScript logging level when set. The property used for setting the log level varies by version:

  • IDM 5.5 and later: org.forgerock.openidm.script.javascript.JavaScript.[script-name].level
  • IDM 5: org.forgerock.script.javascript.JavaScript.[script-name].level


For example, in IDM 7, you could leave the global logging level set to the default INFO. You could then set the following logging levels in to generate only WARN logging for all JavaScript files but output DEBUG information for a specific file (myScript):

.level=INFO org.forgerock.openidm.script.javascript.JavaScript.level=WARNING org.forgerock.openidm.script.javascript.JavaScript.myScript.level=FINE

By setting logging levels in this way, you are not outputting DEBUG and INFO messages for all JavaScript files, only the one you want to debug.

Adding logger code to JavaScript files

Within your JavaScript files, you can then add the appropriate logger code to log to the IDM log.

For example, in the JavaScript file that you want to debug (myScript in the above example), you could add the following:

logger.debug("Test error message logged for user {}", userName);

This example logger will output to your IDM log as:

May 24, 2020 11:27:28 AM org.forgerock.openidm.script.javascript.LoggerPropertyFactory$1$3 call FINE: Test error message logged for user jdoe

Including debug information

By default, debug information (such as file name and line number) is excluded from JavaScript exceptions.

You can set the following property in the file to include this debug information:

The file is located in /path/to/idm/resolver (IDM 6 and later) or /path/to/idm/conf/boot (IDM 5).

See Also

FAQ: Scripts in IDM

Customizing Java Log Format to use SimpleFormatter fails in IDM (All versions)

Security Guide › Adjusting Log Levels

Scripting Guide › Log Functions

Synchronization Guide › Using Scripts to Generate Log Messages

SLF4J Logger

Related Training


Related Issue Tracker IDs


Copyright and Trademarks Copyright © 2021 ForgeRock, all rights reserved.