How to add logging for a scoped application?

amitmparikh
Tera Contributor

Trying to use GSLog for logging in an application scope, but it is restricted to only global scope and inaccessible from a private application scope.

Is there an alternative way of logging for application scope?

6 REPLIES 6

Dave65
Tera Contributor

Can anyone update their links?

Swarup Patra
Kilo Guru

Yes, there is an alternative way of logging for application scope. You can use the GlideSystem method "gs.info()", "gs.debug()", "gs.warn()", and "gs.error()" for logging in application scope. Here is a sample code:

javascript
gs.info('This is an info message');
gs.debug('This is a debug message');
gs.warn('This is a warning message');
gs.error('This is an error message');


Here are the steps to implement it:

1. Open the script or server-side code where you want to add the logging.
2. Use the "gs.info()" method for logging informational messages. This method takes a string as an argument which will be the log message.
3. Use the "gs.debug()" method for logging debug messages. This method also takes a string as an argument.
4. Use the "gs.warn()" method for logging warning messages. This method takes a string as an argument.
5. Use the "gs.error()" method for logging error messages. This method takes a string as an argument.
6. Save and test your script.

Remember, these logs will be visible in the system logs which can be accessed by navigating to "System Logs > All" in the ServiceNow application navigator.


nowKB.com

If you want to know any information about Service Now . Visit to https://nowkb.com/home