gs.log() vs gs.print() difference? which is best and why?

mallikharjunasw
Tera Contributor

gs.log()  vs gs.print() difference? which is best and why?

7 REPLIES 7

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.

Thank you

Thank you,
Abhishek Gardade

Alikutty A
Tera Sage

Hi,

gs.print is used mainly while executing background scripts. They give you instant results while executing your scripts at background on the same page whereas gs.log adds an entry in the syslog table and you need to navigate to the logs table for results. If you are doing a one time execution within background scripts, then you should be using gs.print. If you need logs from any server side scripts then you might need to use gs.log. 

Again gs.log is not preferred to be used with the introduction of new methods available for logging ie gs.info, gs.error etc. These methods are supported in scoped applications as well.

Thanks!

Dilip Puligilla
Giga Guru

HI mallikharjunaswamyvutla

 

The main difference is "gs.log" doesn't work in Scoped Applications. you have to use gs.info() or gs.debug() etc instead.

 

Correct answer from Chuck Tomasi

Didn't you say that this is a scoped app? If so, gs.log is off-limits. Change it to gs.info and see if your script produces output. For best visibility to what's going on, turn on business rule debugging.

 

https://community.servicenow.com/community?id=community_question&sys_id=b51197e9dbdcdbc01dcaf3231f96...

 

Thanks and Regards

Dilip