System Logs With ms Accuracy - Solved

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2023 04:14 AM
For years I've waited for SNOW to provide better logging that shows actions taken in linear sequence to no avail. I recently inherited an app built by a true code monkey with a single script include of 4000 lines. When ran it generates approx 800 lines in the system log. Since it runs within a second or two the log becomes useless given that sequential actions can be logged dozens of lines away from prev/next actions.
This is my solution to log down to the ms (and I can attest it works on large script includes
). You can either add this in your own script include and call it remotely or add it to any Bravo Alpha script include but the heart of the solution is a function like this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2023 11:50 AM
One of our Devs went an alternate route.
Write to the log with an array instead.
Here is an example for Unused Notifications:
checkNotifications();
function checkNotifications() {
var List = [],count=0;
var Notification = new GlideRecord('sysevent_email_action');
Notification.addEncodedQuery('active=true');
Notification.setLimit(10);
Notification.query();
while (Notification.next()) {
var NoteID = Notification.getValue('sys_id');
var LOG = new GlideRecord('sys_email_log');
LOG.addEncodedQuery('notification='+NoteID);
LOG.setLimit(1);
if (!LOG.next()) {
List.push(NoteID);
count++;
}
}
gs.info("Unused Notifications: \n"+count+'\n'+List.join(','));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2024 08:51 AM
Hi, ServiceNow appear to have added an undocumented(?) sequence field to syslog - here.