Blog

Logging for Scoped Applications

The old reliable gs.log statement doesn’t work on scoped applications. If you are trying to debug a script, this will add difficulty to your efforts.

The reason the gs.log statement doesn’t work, is that it is restricted to the global scope and not accessible from a private scope.

Scoped Script Logging

The good news is that you can use these alternative log statements instead

Log level | Description
error (gs.error) | Logs events that might still allow the application to continue running. Setting the log level for an application to error generates error messages only, but does not generate warn, info, or debug messages.
warn (gs.warn) | Logs potentially harmful events. Setting the log level for an application to warn generates error and warn messages, but does not generate info or debug messages.
info (gs.info) | Logs informational messages that describe the progress of the application. Setting the log level for an application to info generates info, warn, and error messages, but does not generate debug messages.
debug (gs.debug) | Logs informational events that are useful for debugging an application. Setting the log level for an application to debug generates info, warn, error, and debug messages.

To find the log statement results:

  1. In Left Navigator Bar

  2. Go to System Logs > Application Logs. Use this instead of Script Log Statements, which is used for gs.log

ServiceNow Developer Page on Scoped Script Logging