Sorting log entries by actual creation order?

mike_sol
Giga Contributor

I'm currently working on a reasonably advanced script, and due to the lack of any other method for debugging I'm using the good old lots-of-logging technique.

However, it seems that timestamp granularity in ServiceNow's syslog table is only down to the second, not the millisecond, and so I can't easily see a list of my logging output in the order I'm actually writing it to the log in. This makes reading the logs infuriating and time consuming.

Not only that, but the sort order is not deterministic - reloading the same view multiple times with a bunch of log entries on the same timestamp will return them in a different order each time. (How the **** does that work?)

Is there any mechanism to view the logs in the order they were written?

9 REPLIES 9

andrew_venables
ServiceNow Employee
ServiceNow Employee

How about using:

var gdt = new GlideDateTime();
gs.log(gdt.getNumericValue() + ' debug statement 1');


mike_sol
Giga Contributor

I've submitted an enhancement request. For the time being I will use that millisecond sequence method that Andrew Venables suggested; a good idea for sure!


Honestly, this must be wasting Thousands of man-hours.  Where may we vote for your enhancement request, Mike?

Andy-L
Tera Contributor

[ Resurrecting this 2013 thread in 2024 to add here in case it helps others]

[Edit - It looks like this was introduced in Washington ]

 

I've just noticed on recent ServiceNow releases, syslog now has a sequence field for sub-second ordering. (not to be confused with the proper counter one that is on the Application Log ) . I'm not sure when it was introduced.


It's not indexed though,  just a hex timestamp string - so you still have to use sys_created_on in the query.

 

At the time of writing it is not documented on the main SystemLogs reference page.

 

AndyL_1-1729266018372.png

 

Absolutely life changing