[SERVER-18605] Include thread id in log messages Created: 21/May/15 Updated: 25/Jan/17 Resolved: 27/May/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Logging |
| Affects Version/s: | None |
| Fix Version/s: | 3.1.4 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Scott Hernandez (Inactive) | Assignee: | Andy Schwerin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Participants: | |||||||||
| Description |
|
When debugging and diagnosing issues it is very helpful for the thread id to be included with each log message. Adding a switch or having this behavior in some special mode may be sufficient for mongodb developers, but I can also see this being useful for diagnosing end-user problems as well. This can be tested by add a line to "MessageEventDetailsEncoder::encode":
|
| Comments |
| Comment by Githook User [ 27/May/15 ] | ||||||||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@mongodb.com'}Message: | ||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 27/May/15 ] | ||||||||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@mongodb.com'}Message: This ensures that some thread name appears in log messages, even if a thread | ||||||||||||||||||||||||||||||||||||||||
| Comment by Andy Schwerin [ 21/May/15 ] | ||||||||||||||||||||||||||||||||||||||||
|
Yeah. I've got a patch for that I'll put up for review. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Scott Hernandez (Inactive) [ 21/May/15 ] | ||||||||||||||||||||||||||||||||||||||||
|
Use a counter? | ||||||||||||||||||||||||||||||||||||||||
| Comment by Andy Schwerin [ 21/May/15 ] | ||||||||||||||||||||||||||||||||||||||||
|
So I did a little experiment. I compiled and ran the following program on Ubuntu 14 using gcc and clang.
The output was similar for both runs:
What concerns me is that the thread id reveals the stack address of the thread. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Scott Hernandez (Inactive) [ 21/May/15 ] | ||||||||||||||||||||||||||||||||||||||||
|
Sounds good to me. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Andy Schwerin [ 21/May/15 ] | ||||||||||||||||||||||||||||||||||||||||
|
How about if instead of this behavior, we set the default thread name to contain the thread id, but if the thread explicitly calls setThreadName, that value is used instead? This could be achieved by altering the implementation of setThreadName slightly. |