Debug log

Pranai
Tera Contributor

.Which is one that performs debug logging in server side?
a. Gs.debug()
b. Gs.log()
c. Gs.print()
d. Gs.info(

2 ACCEPTED SOLUTIONS

Rafael Batistot
Tera Sage

Hi @Pranai 

b) gs.log()


The most commonly used server-side debug methods are:

  • gs.log: used for global applications. This option writes messages to the Log [syslog] table and the localhost log. Also when using Background Scripts it prints the message to the browser screen. 
  • gs.print: used for global applications. This option writes messages to only the localhost log. Also when using Background Scripts it prints the message to the browser screen. 
  • gs.debug: used for scoped applications. This option writes messages to the Log [syslog] table and the localhost log. Also when using Background Scripts it prints the message to the browser screen.

If using gs.log (“message”,”source”), there is a second source parameter available called source. It is essential to use this second parameter as it will make it much easier to find the log output if you want to locate it in the Log [syslog] table.

It is recommended to put your debug statements near the failing area of the script or after a part of the script that you are trying to understand better. Add as much information in the message as needed to make the output more understandable.

See the reference 

ServiceNow Things to Know 88: Debug Server-Side Sc... - ServiceNow Community

View solution in original post

GlideFather
Tera Patron

@Pranai please specify what scope:

  • for Global scope: B or D
  • for Custom scope: D

I always gs.info() everyhwere :))

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


View solution in original post

2 REPLIES 2

Rafael Batistot
Tera Sage

Hi @Pranai 

b) gs.log()


The most commonly used server-side debug methods are:

  • gs.log: used for global applications. This option writes messages to the Log [syslog] table and the localhost log. Also when using Background Scripts it prints the message to the browser screen. 
  • gs.print: used for global applications. This option writes messages to only the localhost log. Also when using Background Scripts it prints the message to the browser screen. 
  • gs.debug: used for scoped applications. This option writes messages to the Log [syslog] table and the localhost log. Also when using Background Scripts it prints the message to the browser screen.

If using gs.log (“message”,”source”), there is a second source parameter available called source. It is essential to use this second parameter as it will make it much easier to find the log output if you want to locate it in the Log [syslog] table.

It is recommended to put your debug statements near the failing area of the script or after a part of the script that you are trying to understand better. Add as much information in the message as needed to make the output more understandable.

See the reference 

ServiceNow Things to Know 88: Debug Server-Side Sc... - ServiceNow Community

GlideFather
Tera Patron

@Pranai please specify what scope:

  • for Global scope: B or D
  • for Custom scope: D

I always gs.info() everyhwere :))

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */