[SERVER-7965] Add Year to Logging Timestamp Created: 17/Dec/12  Updated: 23/Feb/15  Resolved: 19/Aug/13

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: 2.2.2
Fix Version/s: 2.5.2

Type: Improvement Priority: Minor - P4
Reporter: Adam Comerford Assignee: Andy Schwerin
Resolution: Done Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
is duplicated by SERVER-9522 mongod logging to /var/logs should ti... Closed
Backwards Compatibility: Minor Change
Participants:

 Description   

Implementation Details
New command-line option for configuration:

--logTimestampFormat=(ctime|iso8601-utc|iso8601-local)

The beginning of the Unix Epoch is formatted as follows in the three formats, assuming America/New_York for the time zone.

ctime:         Wed Dec 31 19:00:00.000
iso8601-utc:   1970-01-01T00:00:00.000Z
iso8601-local: 1969-12-31T19:00:00.000+0500

Original description
Log parsing with date ranges can be tricky without a year in the timestamp by default, especially near the end/start of the year.

Rather than the current:

Thu Dec 13 16:39:15 [log message]

Perhaps:

Thu Dec 13 2012 16:39:15 [log message]



 Comments   
Comment by Andy Schwerin [ 19/Aug/13 ]

Tools that expect that timestamp to be formatted in "ctime" format may need updating.

Comment by auto [ 19/Aug/13 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@10gen.com'}

Message: SERVER-7965 Change default date format in logs to iso8601-local.
Branch: master
https://github.com/mongodb/mongo/commit/f83c49b25beb75aed0d7d2ced779a4550d566252

Comment by auto [ 26/Jul/13 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@10gen.com'}

Message: SERVER-7965 Make the timestamp format settable in servers.

From the command line or config file, --logTimestampFormat=(ctime|iso8601-utc|iso8601-local).

The beginning of the Unix Epoch is formatted as follows in the three formats,
assuming America/New_York for the time zone.

ctime: Wed Dec 31 19:00:00.000
iso8601-utc: 1970-01-01T00:00:00.000Z
iso8601-local: 1969-12-31T19:00:00.000+0500

The default remains the same as in prior versions, "ctime".
Branch: master
https://github.com/mongodb/mongo/commit/01b4f0ad09c244fd7f83bb045ff844416aa8ca96

Comment by auto [ 24/Jul/13 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@10gen.com'}

Message: SERVER-7965 Fix time_support_test for systems with small (signed, 32-bit) time_t.
Branch: master
https://github.com/mongodb/mongo/commit/25395ab8e296d61a79f52a87020c01ef9ec075e4

Comment by auto [ 24/Jul/13 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@10gen.com'}

Message: SERVER-7965 Fix time_support and time_support_test windows build errors.

This includes manually constructing the timezone offset in ISO 8601 formatted
local times.
Branch: master
https://github.com/mongodb/mongo/commit/546fc3686e659b44a0145bb62c8e2897abf31bb2

Comment by Andy Schwerin [ 24/Jul/13 ]

Proposal:

New command-line option for configuration:

--logTimestampFormat=(ctime|iso8601-utc|iso8601-local)

The beginning of the Unix Epoch is formatted as follows in the three formats, assuming America/New_York for the time zone.

ctime:         Wed Dec 31 19:00:00.000
iso8601-utc:   1970-01-01T00:00:00.000Z
iso8601-local: 1969-12-31T19:00:00.000+0500

The last open decision is to choose an appropriate default. iso8601-local is appealing because it is reports time in host's time zone, but provides enough information to find the UTC time. The cost is an extra 4 bytes per log line over the iso8601-utc form.

Comment by auto [ 24/Jul/13 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@10gen.com'}

Message: SERVER-7965 Move date/time types and functions from bson/util/misc.h to util/time_support.

{h,cpp}

.
Branch: master
https://github.com/mongodb/mongo/commit/d10114734e1e718f1184714d0d0db8b7ccd70e10

Comment by auto [ 24/Jul/13 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@10gen.com'}

Message: SERVER-7965 Construct MessageEventEphemeral with a time stamp; use that when printing log messages.
Branch: master
https://github.com/mongodb/mongo/commit/66d94037a5c2498809abc2c596f2c7a2e332068d

Comment by auto [ 24/Jul/13 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@10gen.com'}

Message: SERVER-7965 Introduce time formatting functions for ISO 8601 and Ctime; eliminate curTimeString().
Branch: master
https://github.com/mongodb/mongo/commit/0c9209c6d59477eadf27697999f6af59d931251c

Comment by Daniel Pasette (Inactive) [ 23/Jul/13 ]

Plan is to change default to ISO-8601 with option to use current format.

Comment by Justin Case [ 27/May/13 ]

I would prefer an ISO 8601 timestamp.

Comment by Thomas Rueckstiess [ 17/Feb/13 ]

The weekday name is redundant and could be replaced by the year.

If we replace the first element (weekday name) with the year, we would also keep the number of space-separated tokens constant, causing minimal damage to existing log parsers that rely on the positions of certain tokens.

2012 Dec 13 16:39:15 [log message]

Another consideration: Use ISO 8601 and replace month names by month numbers to make log lines sortable by date. This could become useful for future log parsing tools.

2012-12-13 16:39:15 [log message]

Generated at Thu Feb 08 03:16:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.