The CreatorCon Call for Content is officially open! Get started here.

What is the difference between gs.log() and gs.print()?

antonymirza
Tera Expert

I have a confusion when to use what i.e. gs.log() or gs.print() as both [gs.log() and gs.print()] writes to system log file.

Anybody please explain the difference...

1 ACCEPTED SOLUTION

eric_szonyi
ServiceNow Employee
ServiceNow Employee

I believe gs.print() will write an entry to the Log File, while gs.log() will write to both the System Log and the Log File as well as give you an option to specify the Source. Both default to "*** Script".


View solution in original post

10 REPLIES 10

eric_szonyi
ServiceNow Employee
ServiceNow Employee

I believe gs.print() will write an entry to the Log File, while gs.log() will write to both the System Log and the Log File as well as give you an option to specify the Source. Both default to "*** Script".


Where to see gs.print()..Thanks


gs.print is more for the Scripts - Background. (imo)


It will print to the screen so you don't need to go to the log to see your message.


This was helpful. My script, which I ran using the "Scripts - Background" tool, took so long that I walked away while it was executing. I did not see the output of the gs.print() statements display on the screen (because I walked away) so I was searching for where they had been stored.

 

Now that it is suggested that they are printed to the screen, I will stick around next time that I execute this script in the background, so that I can see (and capture) the output on the screen.