How to see the output of gs.debug() function

Johannes Mweli
Giga Guru

Hi ServiceNow Community Developers,

If I am using the gs.debug() function in a scoped application where do I go to see the output that was printed out by the function?

For instance, if I use gs.log() in a global application I normally navigate to "Script Log Statements" and I would see the output there. For gs.debug() how & where do I see the output? Please advise.

Thanks,

Johannes

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Go to the sys_app table (e.g. type sys_app.list in the Application navigator search box), find your scoped app record in the list and open it.

Down in the Related links, you'll see "enable session debugging" - click it.

You'll then see your gs.debug/gs.info/gs.warn/gs.error statements at the bottom of standard lists and forms and as of New York, you'll also see them in the Script Debugger on the session log tab.

There may be an easier way, but this is how I do it (since System Applications> Applications no longer brings you to sys_app.list).

View solution in original post

6 REPLIES 6

Chuck Tomasi
Tera Patron

FYI - A response to this post was featured on the Community Live Stream video. I invite you to watch the episode.

Video: Community Live Stream - 2020-01-06 - Developer Community - ServiceNow Community

Geoffrey_Bishop
Giga Expert

This may be helpful to someone.  Expanding on the above answers...  I find gs.log to be the most useful, because you can specify a Source parameter, and then filter the syslog table based on that value.  gs.info, gs.error, and gs.warn are also very straightforward, and tiny bit less error-prone.  Examples:

//SERVER SIDE DEBUGGING
gs.log("My gs.log message", "Phoenix"); //Log to table: syslog. Source "Phoenix". Level "Information".
gs.info("My gs.info message");
gs.error("My gs.error message");
gs.warn("My gs.warn message");

Output:

find_real_file.png

 

gs.debug works differently from all the others.  Example:

gs.debug("My gs.debug message"); //Shown below FORM on client, *IF* "System Diagnostics - Session Debug" is first set to ON for the "log" object type.  Also shown in the separate Session Log Window.

IF you have first enabled Session Logging for the "Log" object type...

find_real_file.png

And double-checked this in your Session Log window...

find_real_file.png

And then you trigger your code which makes a gs.debug() call... 

THEN, you should be able to find the message in the Session Log Window...

find_real_file.png

Or, underneath the main content of a form, back on the client side.

find_real_file.png

But again, these gs.debug() messages will NEVER show up in the syslog table.