[SERVER-4217] add log severity and component name to the log message Created: 04/Nov/11  Updated: 03/Jan/18  Resolved: 29/Jul/14

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: None
Fix Version/s: 2.7.5

Type: Improvement Priority: Minor - P4
Reporter: Dominik Gehl Assignee: Benety Goh
Resolution: Done Votes: 12
Labels: polish
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
is duplicated by SERVER-7662 Improve error and warning reporting i... Closed
is duplicated by SERVER-4108 server logfile lines should include a... Closed
Related
related to SERVER-14729 Add log component to non-debug messages Closed
related to SERVER-85138 guide for log messages and debug levels Closed
related to SERVER-16127 Display numeric debug log level in ou... Closed
is related to SERVER-15499 Confusion with error message "Asserti... Closed
is related to SERVER-5092 Better named logging with tracing Closed
Tested
Sprint: Server 2.7.4, Server 2.7.5
Participants:
Case:
Linked BF Score: 0

 Description   

New format:

Log severity is logged with a single capital letter.
F - Fatal
E - Error
W - Warning
I - Info and Debug Level 0
D - All debug levels > 0
Component name is logged in upper-case padded with trailing spaces to fit within 8 characters.
Default log component is displayed with a hyphen.

--------------

It would be immensely useful if the mongo log would contain for each message the given log level. Currently it's almost impossible to do some automatic log querying (for example with logwatch) since you have to manually filter based on regular expressions what could possible be interesting to see. If a log level was saved with the log message, it would be possible to simply grep for 'warning' or 'error'



 Comments   
Comment by Githook User [ 28/Aug/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-4217 use hyphen to display default component in log message
Branch: master
https://github.com/mongodb/mongo/commit/1d46ac81bb65d8065f7667103d25abcef6fbf897

Comment by Githook User [ 30/Jul/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-4217 fixed regular expression in multiVersion balancer test so that the test is not dependent on the log format
Branch: master
https://github.com/mongodb/mongo/commit/f7df4c7dcfabbadb4fde07018f85d00bc8ba47a0

Comment by Derick Rethans [ 30/Jul/14 ]

Looks good - the only thing I would possible consider is to not have an empty field, like is done here for the ```dropAllDatabasesExceptLocal``` entry:

 m31001| 2014-07-30T02:12:31.545-0400 I REPLSETS [rsSync] replSet initial sync drop all databases
 m31001| 2014-07-30T02:12:31.545-0400 I          [rsSync] dropAllDatabasesExceptLocal 1
 m31001| 2014-07-30T02:12:31.546-0400 I REPLSETS [rsSync] replSet initial sync clone all databases

I think it'd make sense to have something there - for easier parsing.

Comment by Benety Goh [ 30/Jul/14 ]

Sample log output from replicasets/reindex_secondary.js:

 m31001| 2014-07-30T02:12:31.543-0400 I REPLSETS [rsSync] replSet initial sync pending
 m31001| 2014-07-30T02:12:31.543-0400 I REPLSETS [rsSync] replSet syncing to: ip-10-179-157-232:31000
 m31001| 2014-07-30T02:12:31.545-0400 I INDEXING [rsSync] build index on: local.replset.minvalid properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "local.replset.minvalid" }
 m31001| 2014-07-30T02:12:31.545-0400 I INDEXING [rsSync] 	 added index to empty collection
 m31001| 2014-07-30T02:12:31.545-0400 I REPLSETS [rsSync] replSet initial sync drop all databases
 m31001| 2014-07-30T02:12:31.545-0400 I          [rsSync] dropAllDatabasesExceptLocal 1
 m31001| 2014-07-30T02:12:31.546-0400 I REPLSETS [rsSync] replSet initial sync clone all databases
 m31001| 2014-07-30T02:12:31.546-0400 I REPLSETS [rsSync] replSet initial sync cloning db: admin
 m31001| 2014-07-30T02:12:31.547-0400 I REPLSETS [rsSync] replSet initial sync data copy, starting syncup
 m31001| 2014-07-30T02:12:31.547-0400 I          [rsSync] oplog sync 1 of 3
 m31001| 2014-07-30T02:12:31.547-0400 I          [rsSync] oplog sync 2 of 3
 m31001| 2014-07-30T02:12:31.547-0400 I REPLSETS [rsSync] replSet initial sync building indexes
 m31001| 2014-07-30T02:12:31.547-0400 I REPLSETS [rsSync] replSet initial sync cloning indexes for : admin

Comment by Githook User [ 29/Jul/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-4217 updated detailed log format to include log severity and component name.

Log severity is logged with a single capital letter.
F - Severe
E - Error
W - Warning
I - Info and Debug Level 0
D - All debug levels > 0
Component name is logged in upper-case padded with trailing spaces to fit within 8 characters.
Branch: master
https://github.com/mongodb/mongo/commit/c91a2c3392fc95be3ed07ba98a4d98b4db754b58

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