sorting - Sortable, readable and standard time format for logs -


timestamp format in logs

most log lines contain timestamp , 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 trying find standard timestamp log lines. criteria is:

  1. human readable. want understand when did event happen.
  2. alphabetically sortable. when grep events few files , sort them using posix sort or word/excel, want alphabetical sort adhere chronological sort. example, [23/jul/2012:19:35:11 +0000] , [22/jul/2013:19:35:11 +0000] not sortable - 2013 line appear before 2012 line.
  3. easily parsable common languages. timestamp should parsed using standard strptime if log processed script.

the standard i've found far iso_8601, has many variants (e.g. 2007-04-05t14:30z , 2007-03-01t13:00:00z), , lacks definite standard log line events.

could recommend standard timestamp format log lines?

enter image description here

@j.f. sebestian - comment.

after research chose rfc 3339 / iso 8601 in utc, e.g.:

date -u "+[%y-%m-%d %h:%m:%s%z (%z)]"       # space separated tz abbreviation [2013-07-31 23:56:34+0000 (utc)]                     date -u "+[%y-%m-%d %h:%m:%s.%n %z (%z)]"  # space separated nanoseconds , tz abbreviation [2013-07-31 23:56:34.812572000 +0000 (utc)] 

features:

  • sortable (most significant date item on left)
  • readable
  • unambiguous, time zone stated
  • delimited [,], useful regexing date away
  • easily parsable
  • accurate: uses nanoseconds (might practically milliseconds on machines, enough)

i've created nice github project helps date formatting - feel free take , suggest own formats!


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -