Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

This is related to my question in stackoverflow where vb.net simply hang on updating a mongodb query.


After long soul searching we check the log. The log is 3GB in size.

A log with that size is absolutely useless. I cannot have any text editor to open it.

How to keep the log of mongodb small, say 50 mb max.

We are only interested in the last few commmand anyway not the whole log.

Is there a setting for that in MongoDB? If so what settings:

Note: The question is simmilar with: http://stackoverflow.com/questions/8777449/mongodb-log-file-size

However, that question doesn't ask

How do I do so by changing some text files or something persistent so that the setting remain every time I start mongodb.

share|improve this question
Check this post, it holds the same question. stackoverflow.com/questions/8777449/mongodb-log-file-size –  SwissCoder Oct 9 '12 at 9:28
For a 3GB text file, you may find a pager more helpful than a text editor. Just sayin'. Also see grep, awk, sed, less, tail, head, and tac. –  Chris Travers Oct 9 '12 at 10:05
By the way should I delete this question due to the exact duplicate? –  Jim Thio Oct 9 '12 at 10:13
Actually I modified the question a little bit. I want to know how to do so permanently or set that as default. –  Jim Thio Oct 9 '12 at 10:16

2 Answers 2

Have a look at log rotation. mongo log rotation

It will allow you to automatically create multiple smaller log files, much like web server logs. Just delete the older ones as you go.

And as Chris points out, you just need a decent text processor that can accommodate 3GB files. The list is surprisingly short on those that properly memory map files, but notepad certainly isn't one of them as it just tries to load the whole file into RAM like many others. Alternatives are easy to find, but your mileage may vary: large gb text editors

Personally, I keep "tail -f" running on my Mongo log file and it's always running in an window I can refer to.

share|improve this answer

You might already know the answer just posting the answer here for someone else like me ending in this post :D

vi /etc/mongo.conf
smallfiles = true

This would set smallfiles true once you restart your mongodb.

share|improve this answer
Thanks for contributing an answer to this question. Can you give a little more detail on the smallfiles option to round out the answer? –  Erik yesterday

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.