|
MongoDB outputs some important information to stdout while its running. There are a number of things you can do to control this Command Line Options
Rotating the log filesLog file rotation renames the current log file to the same name with a timestamp file extension appended, then continues logging to a new file with the original name. The timestamp is the time that the logRotate command was executed, expressed in UTC (GMT) and formatted as ISO but with dashes instead of colons for the time portion. For example: $ ./mongod -v --logpath /var/log/mongodb/server1.log --logappend
will start mongod with verbose logging to /var/log/mongodb/server1.log, appending to any existing log file. In another terminal, list the matching files: $ ls /var/log/mongodb/server1.log*
server1.log
Rotate the log file using one of the methods described below, then list the files again: $ ls /var/log/mongodb/server1.log*
server1.log server1.log.2011-11-24T23-30-00
This indicates a log rotation performed at exactly 11:30 pm on November 24th, 2011 UTC, which will be the local time offset by the local time zone. The original log file is the one with the timestamp, and new log lines are now being written to the server1.log file. If another logRotate command is given one hour later, an additional file will appear: $ ls /var/log/mongodb/server1.log*
server1.log server1.log.2011-11-24T23-30-00 server1.log.2011-11-25T00-30-00
The server1.log.2011-11-24T23-30-00 file is unchanged from before, while server1.log.2011-11-25T00-30-00 is the previous server1.log file renamed and server1.log is a new empty file that will receive new log output. From the mongo shell> use admin
> db.runCommand("logRotate");
From the unix shellRotate logs for a single process shell> kill -SIGUSR1 <mongod process id> Rotate logs for all mongo processes on a machine shell> killall -SIGUSR1 mongod
Accessing Logs via ShellNew in 1.9.x Get a list of available loggers
> show logs
> db.runCommand( { getLog : "*" } )
Get a log
> show log global
> db.runCommand( { getLog : "global" } )
|

PLEASE POST QUESTIONS IN THE FORUMS: http://groups.google.com/group/mongodb-user. Post tips and clarifications here.
blog comments powered by Disqus