Logging in scoped applications

As we discovered when we looked at gs.log, it does not work in scoped applications. For logging in scoped applications, we need to use a different method. In fact, there are four methods that can be used.

The four levels of logging in a scoped application are:

  • Error
  • Warn
  • Info
  • Debug

This type of logging works in a very similar way to gs.log, but with the different levels of log replacing the word log after gs

Let's have a look at how to write a basic script for each:

gs.error('Error log');gs.warn('Warn log');gs.info('Info log');gs.debug('Debug log');

These logs are visible in the application logs table, which can be viewed by going to System Logs | System Log | Application Logs

By default, when you create ...

Get Mastering ServiceNow Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.