The Scripting API in AM uses the logger object to log debug messages from scripts to the AM debug logs. Debug logging in scripts is not enabled by default; you must enable it by setting the debug log level for the amScript service.
Debug log messages from scripts are logged to the following AM debug logs depending on the type of script:
|Script type||Log file|
|OAuth 2.0 Access Tokens (AM 6.5 and later)||OAuth2Provider|
The available logger methods that can be used are detailed in: Getting Started with Scripting › Debug Logging.
AM 7 uses Logback for configuration of debug logging. Any scripts that create debug messages have their own logger, which is only created after the script has executed at least once.
See Maintenance Guide › To Temporarily Enable Debug Logging with Logback.jsp for further information.
This example shows how you would output an error message in the Authentication log for an authentication-related script. The log level selected and the log level specified in the script should match, else a message will not be output.
- Set the required debug level for the amScript service by navigating to the Debug.jsp page, for example: http://host1.example.com:8080/openam/Debug.jsp and setting the following fields:
- Select the Authentication debug file from the Category field.
- Select Scripting from the Debug instances field.
- Select Error from the Level field.
- Click Submit to change the debug level.
- Update your script to include the required logger code. You can either do this via the Console or the REST API depending on how you manage your scripts. For example, you could add the following to the script you want to debug: logger.error("Test error message logged for Authentication"); This message will output to the Authentication log when the script is run.