Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB log file

I'm having problems with my configuration log file. I'm trying to log all operations but the only ones that are saved are the SERVER RESTARTED . My configuration file:

##store data here
dbpath=C:\data\db

profile=2

##all output go here
logpath=C:\mongodb\log\mongo.log

logappend=true
##log read and write operations
diaglog=3

What am I missing? and is there a way to configure mongo log file with java spring somehow (maybe xml)?

like image 631
lior Avatar asked Feb 06 '14 09:02

lior


People also ask

Where is the MongoDB log file?

MongoDB logs can be found in the MongoDB log files at /var/log/mongodb/mongodb. log. If you can't find the log files from this location, you can check the mongodb. conf.

Is it safe to delete MongoDB log file?

You can also trigger log rotation using MongoDB's logrotate administrative command, which might be useful as a first step to allow you to compress or archive your current large log file. I wouldn't outright delete recent log files until you are certain you won't need them for any diagnostic purposes.

What is MongoDB log?

As part of normal operation, MongoDB maintains a running log of events, including entries such as incoming connections, commands run, and issues encountered. Generally, log messages are useful for diagnosing issues, monitoring your deployment, and tuning performance.

Where are MongoDB logs stored Windows?

Default, MongoDB creates the log file at this path /var/log/mongodb/mongodb. log , if the log file is not found, please check with the MongoDB config file.


1 Answers

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());
like image 190
Stennie Avatar answered Sep 29 '22 16:09

Stennie