Generic function to enabe or disable gs.log statements from script include

Neelavathi M
Tera Contributor

Hi All,

I have requirement to minimize the logging information in Prod for better optimization.

so i have created a system property and set it true and created a script include to call that system property , inside what generic gs.log stmt can be given , can someone help me with this pls ,so that it can be called from any of the scripts .

example of gs.log stmts: these are from difft scripts , want generic function to call from other scripts.

 

gs.log('ret.getHeader ' + request.getHeader(), 'Or-Incident');

gs.log('Multiset created&updated: ' + multiCCreated + ' : ' + multtUpdated);

gs.log(info, 'Transform');

gs.log("11 - Pplink sct gets through variable");

 

NeelavathiM_0-1767965626053.png

 

Thanks in Advance.

 

4 REPLIES 4

Ankur Bawiskar
Tera Patron

@Neelavathi M 

Don't use gs.log() as it doesn't work in scoped app, please use gs.info()

check these blogs

Community Code Snippets: Using a System Property to Control Logging 

Managing syslog Growth in ServiceNow 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Neelavathi M 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Shashank_Jain
Mega Sage

@Neelavathi M ,

Instead of gs.log use gs.info or logger.log, if your script running in a scoped application.

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain

Sandeep Rajput
Tera Patron

@Neelavathi M Instead of reinventing the wheel with a custom script include, I recommend you to explore GSLog utility. This serves the same purpose for more details please refer to https://www.servicenow.com/docs/de-DE/bundle/zurich-api-reference/page/app-store/dev_portal/API_refe...

 

Hope this helps.