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

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Here's some info. And both you mentioned are both not best 🙂

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Oleg
Mega Sage

The difference is described in the documentation: gs.print() writes a message to the system log only, but gs.log() writes additionally the same information in syslog table. Additionally gs.print() can be not used in scoped application, where one have to use gs.debug() instead of gs.print() or gs.log() of cause. 

Strange that the docs page - on Madrid - uses gs.log. Because gs.log / gs.print are outdated for already some years 😞

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

AbhishekGardade
Giga Sage

Hello

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".

https://docs.servicenow.com/bundle/london-application-development/page/script/useful-scripts/referen...

https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_GS-print_S

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

Thank you,
Abhishek Gardade