Timestamp format in logs
Most log lines contain a timestamp and event description:
[When] [What]
e.g.:
[23/Jul/2013:19:35:11 +0000] Processing started.
[23/Jul/2013:19:36:11 +0000] Processed 1000 items.
[23/Jul/2013:19:37:11 +0000] Processing finished successfully.
I am trying to find a standard timestamp for my log lines. My criteria is:
- Human readable. I want to easily understand when did the event happen.
- Alphabetically sortable. When I
grep
events from a few files and sort them using POSIXsort
or even word/excel, I want the alphabetical sort to adhere to chronological sort. For example,[23/Jul/2012:19:35:11 +0000]
and[22/Jul/2013:19:35:11 +0000]
are not sortable - the 2013 line would appear before the 2012 line. - Easily parsable by all common languages. The timestamp should be easily parsed using standard strptime if the log is processed by a script.
The only standard I've found so far is ISO_8601, which has many variants (e.g. 2007-04-05T14:30Z
and 2007-03-01T13:00:00Z
), and lacks a definite standard for log line events.
Could you recommend a standard timestamp format for log lines?