[SERVER-4905] logRotate should conform to standard log rotation mechanisms Created: 07/Feb/12 Updated: 27/Oct/15 Resolved: 10/Jun/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Logging |
| Affects Version/s: | 2.0.2, 2.1.0 |
| Fix Version/s: | 2.7.2 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Michael A. Fiedler | Assignee: | Mark Benvenuto |
| Resolution: | Done | Votes: | 23 |
| Labels: | cap-ticket-needed, community-team | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
linux (ubuntu/centos) |
||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sprint: | Server 2.7.2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
logrotate is a system handler that deals with log files. It is a commonly-used solution across most popular linux distributions. MongoDB server files are always open by the server, from documentations it shows that one should call the "logRotate" method, either from a signal or through the mongo shell. Since the logRotate command names the files in a non-logrotate valid format, handling these is not a good solution for automatic "rolling" logs, that auto-expire based on directives. I believe the code that handles the naming is here: https://github.com/mongodb/mongo/blob/master/src/mongo/util/log.cpp#L108-127 Here's a user's solution on handling the logrotation, and it seems a little like overkill: http://syslog.warten.de/2011/08/logrotate-with-mongodb/ From the man page:
Logroate (without copytruncate directive) moves the current (open) file to filename.1 (and any older ones to .2 ,.3 etc). So it seems like we should be allowing logrotate to handle the naming, expiration, either by default, or by a variable in the logRotate method, or possible a differenc command like "startNewLogFile" or something. |
| Comments |
| Comment by Githook User [ 06/Jun/14 ] |
|
Author: {u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}Message: To support the standalone utility, we need to give administrators |
| Comment by Andy Schwerin [ 22/Jul/13 ] |
|
With the resolution of I imagine that RFW would get a new "reopen" method, and RFM would get a reopenAll() method. Then, it's just a matter of configuring the behavior of the rotateLogs() method in mongo/util/log.cpp to call manager->reopenAll() instead of rotateAll(), when the user has configured mongod in that manner. Choosing a startup-time setParameter or a command line parameter name is probably the hardest part of the task. |