Windows log rotation

401 views
Skip to first unread message

Simon Dean

unread,
May 24, 2011, 5:43:42 AM5/24/11
to mongod...@googlegroups.com
I know that the logRotate command doesn't work in Windows.  However, there is also no SIGUSR1 in Windows and mongod locks the log files, so currently I can't see a way at all to truncate/rotate the logfiles mongod creates.

Anybody got any ideas?  It makes a production mongo install on Windows a bit of a challenge!

Many thanks

Simon

Nat

unread,
May 24, 2011, 5:44:59 AM5/24/11
to mongod...@googlegroups.com
You can send a command logRotate using any drivers:

db.runCommand("logRotate");

Simon Dean

unread,
May 24, 2011, 5:52:45 AM5/24/11
to mongod...@googlegroups.com

Wow fast!  Unfortunately that doesn't seem to work when mongod runs on a Windows server.  I've tried it from a mongo shell & through pymongo and always get 'access denied'.  Btw I'm running mongod as a windows service.

Any other help?

Thanks

Nat

unread,
May 24, 2011, 6:10:28 AM5/24/11
to mongod...@googlegroups.com
Sorry, I forgot that this hasn't been implemented yet: https://jira.mongodb.org/browse/SERVER-2612. Please vote on it.

Simon Dean

unread,
May 24, 2011, 6:14:21 AM5/24/11
to mongod...@googlegroups.com
Okay, done - but the question still remains...how do I get round this?  Anybody any suggestions as to how to rotate the logs on Windows?

Nat

unread,
May 24, 2011, 6:52:37 AM5/24/11
to mongod...@googlegroups.com
currently, mongodb hold exclusive lock to the file, so i don't think it's possible.

Simon Dean

unread,
May 25, 2011, 5:32:31 AM5/25/11
to mongodb-user
Thanks for all the speedy help Nat. Unfortunately that makes moving
mongodb to a Windows server production system (I'm developing
currently) a real pain!

Nat

unread,
May 25, 2011, 5:39:15 AM5/25/11
to mongod...@googlegroups.com
If you *really* want to do it, you can write a small wrapper around mongodb to start it as a service by using command line and let the log go to standard console and redirect it to a tool like chronolog http://cronolog.org/
Reply all
Reply to author
Forward
0 new messages