MongoDB log file MongoDB log file mongodb mongodb

MongoDB log file


In general you do not want to use the diaglog configuration option as the diaglog binary files are both very verbose and also difficult to work with. With this setting enabled you will get a sequence of files in your dbpath directory named diaglog.<time in hex>. You can replay these files using the mongosniff tool, but this approach is mostly intended for driver/server development rather than end user troubleshooting.

FYI, the diaglog option has actually been deprecated as at MongoDB 2.6 (ref: SERVER-12149).

To log queries you should instead be looking at the Database profiler which can be enabled either globally (as you have done in your config with with profile=2) or per-database.

The profiling data will be saved in a capped system.profile collection with a default size of 1Mb per database. If you want to collect more history, you can create a larger system.profile collection.

Note that it is not recommended to run with profiling level 2 in production, as that will generate a write for every query to your database.

is there a way to configure mongo log file with java spring somehow (maybe xml)?

I wouldn't expect a driver to have options to configure the MongoDB server.

You can, however, invoke the profile command via the Java driver to adjust profiling options at runtime.

For example, you could enable profiling level 2 with something like:

db.command(BasicDBObjectBuilder.start().add("profile", 2).get());