How to display milliseconds in logs?

Stephen W_
Giga Guru

The sys logs, (warning, error, all) only display the created date in seconds.

The problem is, there are a lot of activities that then are grouped in the same second, and I lose my order of operations making troubleshooting a whole lot more difficult.

 

Can I alter the detail level?

 

Thanks,

-Stephen

12 REPLIES 12

casey_stinnett
Giga Expert

If you are printing to the log table, then using a debug function that prints out the milliseconds can be very helpful. Here is my default debug function:



function debug (message) {


  gs.log('[' + new Date().getTime() + ']' + message, '<Name of Script>');


}



The call to new Date().getTime() will print out in epoch time (basically, milliseconds) when the function was called.



Then you can go to your logs, filter on your script name that you passed in to the gs.log function, and then you can sort by message, descending.



Does this help?


That does help.   Not quite what I was asking though.



Is it not possible to change how the existing date fields display in the log?


Not that I am aware of. The whole of SN is set up with HH:MM:SS. I just looked around and couldn't find anything that used milliseconds. Maybe somebody knows something that I don't and can correct me on this.



Is it code that you are working with? If so, then the debug function I gave you is the best option. If it is not code, then I suppose you will just have to guess at the seconds. (Although I don't know how else to post in the logs without code)


I just tried this out in Jakarta and the logs never show the <Name of Script>, so I still can't sort chronologically.