In a privately-scoped application, which methods are used for logging messages in server-side scripts?
Choose 2 answers
Correct Answer: A,C
In ServiceNow, when developing within a privately-scoped application, certain logging methods are recommended for use in server-side scripts to ensure proper logging and debugging. The GlideSystem (gs) object provides several methods for this purpose:
* gs.debug():
* Description: Logs messages at the "Debug" level.
* Usage: gs.debug('Debug message here');
* Purpose: Useful for logging detailed information during development and troubleshooting. These messages are typically only visible when the system's logging level is set to "Debug."
* gs.error():
* Description: Logs messages at the "Error" level.
* Usage: gs.error('Error message here');
* Purpose: Used to log error messages that indicate a problem that might still allow the application to continue running.
* gs.warn():
* Description: Logs messages at the "Warning" level.
* Usage: gs.warn('Warning message here');
* Purpose: Used to log potentially harmful situations that are not necessarily errors but may require attention.
* gs.info():
* Description: Logs messages at the "Information" level.
* Usage: gs.info('Information message here');
* Purpose: Used to log informational messages that highlight the progress of the application at a coarse-grained level.
Deprecated or Unsupported Methods in Scoped Applications:
* gs.log():
* Description: This method is not supported in scoped applications. It is restricted to the global scope and is not accessible from a private scope. Therefore, it should be avoided in privately- scoped applications.
Reference: Logging for Scoped Applications - ServiceNow Elite
gs.logError():
Description: This method is not a standard GlideSystem logging method in ServiceNow. The appropriate method to log errors is gs.error().
Reference: For more detailed information, please refer to the official ServiceNow documentation on Scoped GlideSystem Logging Methods.