gs.log() vs gs.print() difference? which is best and why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 06:48 AM
gs.log() vs gs.print() difference? which is best and why?
- 30,025 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 06:51 AM
Hi there,
Here's some info. And both you mentioned are both not best 🙂
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 07:04 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 07:07 AM
Strange that the docs page - on Madrid - uses gs.log. Because gs.log / gs.print are outdated for already some years 😞
Kind regards,
Mark
---
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2019 07:28 AM
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://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