Understanding Scoped Applications:
Scoped applications in ServiceNow are designed to isolate and protect application-specific code and
data. Server-side scripts within scoped applications can use the gs (GlideSystem) object for logging
and debugging purposes. However, not all gs methods are appropriate or valid for scoped
applications.
Valid Logging Methods in Scoped Applications:
gs.info():
This method logs informational messages to the system log. It is commonly used for general-purpose
logging when developers need to track execution flow or display debug data. Example:
gs.info('This is an informational log message.');
gs.error():
This method logs error messages to the system log. It is used to indicate problems or issues
encountered during script execution. Example:
gs.error('An error occurred during script execution.');
Incorrect Options Explained:
gs.debug() (Option B): This method is not valid in scoped applications. It is a legacy logging method
available in the global scope but restricted in scoped applications.
gs.iog() (Option C): This is a typographical error and not a valid gs method in ServiceNow.
gs.logError() (Option E): This is not a recognized ServiceNow API method. To log errors, gs.error() is
used instead.
Best Practices for Logging:
Logging should be meaningful and avoid unnecessary entries to keep logs clean and manageable.
Avoid excessive use of logging in production environments, as it can clutter the system logs and
potentially degrade performance.
Reference:
ServiceNow Developer Documentation on GlideSystem (gs) .
SN Pro Tips on debugging and logging practices in scoped applications .