Debug log

Pranai
Tera Expert

.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
Kilo Patron

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

If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct. Doing so helps other users find accurate and useful information more easily.

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 :))

_____
No AI was used in the writing of this post. Pure #GlideFather only

View solution in original post

3 REPLIES 3

Rafael Batistot
Kilo Patron

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

If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct. Doing so helps other users find accurate and useful information more easily.

GlideFather
Tera Patron

@Pranai please specify what scope:

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

I always gs.info() everyhwere :))

_____
No AI was used in the writing of this post. Pure #GlideFather only

d is not global scope it  is scoped