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

Could you please let me know which is System log and which is application log, Log file and where to find in the nav bar??

justin_drysdale
Mega Guru

gs.log takes 2 arguments, level and message.


GSLog - ServiceNow Wiki



gs.print takes 1 argument, message.


GlideSystem - ServiceNow Wiki



gs.log is more robust but both are highly redundant.


DINESH CHINNAD1
Giga Expert

Thanks Antony Mirza for asking this valuable question.



Hi justin.drysdale



i got your points like



gs.log("hi","how are you") have 2 parameter (traceProperty,caller)


gs.log("let","me know"); writes a message to system log and syslog table.



gs.print("hello"); have 1 parameter (message)


gs.print("welcome"); writes a message to system log only



is that correct??? are anything else i have to know about this



I want little more clarification about gs.log() with clear definition with example


sergiu_panaite
ServiceNow Employee
ServiceNow Employee

Hello Antony,



eric.szonyi is right, gs.print() will only print in the application log (Tomcat log file) while gs.log() will print in both application log and syslog table (System Logs).



Regards,


antonymirza
Tera Expert

Thank you all for your valuable inputs!!!