Using Google Chrome?

Download my
free Chrome Extension, Power Notes Searcher, to make searching for and evaluating SAP notes, much easier.

Recent Posts

Thursday, April 21, 2016

Convert SAP AS Java Trace Timestamp

Print Friendly and PDF
Sometimes, just sometimes, you wish you could just take a look at the defaulttrace.log or one of the other many log files at the O/S level for an SAP AS Java based system.
Except, it’s not that simple.  Whilst the file is text based, you’re not able to read the date/time stamp that exists on each line.
Well, here’s a simple couple of methods to do this conversion, which is basically converting from the epoch.
The first method is using a pure Korn Shell (KSH) method, useful for converting maybe one or two values:
dt=1435140894139
echo $(date -d "1970-01-01 ${dt:0:10} seconds")
This second method uses AWK which makes it much better at converting all values by simpling piping in the original file to see the output:

NOTE: Below I’m searching for entries related to “com.sap.engine.services.httpserver.server.log”.
NOTE 2: The below command is all on one line.
cat responses.0.trc | awk -F# '/com.sap.engine.services.httpserver.server.Log/  { print strftime("%F %T",substr($4,1,10))"#"$24 }'


No comments: