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

danpatino
Tera Expert

Use gs.info() instead.   The results end up in System Logs >> Application Logs instead of Script Log Statements.



Scoped GlideSystem API Reference - ServiceNow Wiki


danpatino
Tera Expert

Amit, Does this answer your question?   If so, please mark it as the correct answer.   Thanks!


The SN Nerd
Giga Sage
Giga Sage

Scoped API for logging



The Scoped Logging API provides four levels of verbosity. In order from least verbose to most, they are:


Log LevelDescription
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 error 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.

Best practice for scoped applications is to create two system properties to control the destination of verbosity of logging.



All scoped applications have two properties for control logging verbosity and destination. System properties are available by application for configuring log verbosity and destination, and for turning session debugging on or off:


PropertyDescription
scope_name.logging.destination

Configuring the log destination: file system or db.


  • Type: String
  • Default value: db
  • Location: System Property [sys_properties] table
scope_name.logging.verbosityConfigures log verbosity: error, warn, info, debug, or trace.
  • Type: String
  • Default value: info
  • Location: System Property [sys_properties] table


Scoped Script Logging - ServiceNow Wiki



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Amit,



You may find the below link on developers portal helpful with detailed examples.


https://developer.servicenow.com/app.do#!/document/content/app_store_doc_scoped_script_fuji_c_Scoped...