I remember a few days ago a small partner to check the MongoDB log, so as to troubleshoot problems, may not find the log where the logs, today, the system said MongoDB log system. There are four main types of logs in MongoDB. are system log, journal log, Oplog master-slave log, slow query log, etc. These logs record the different handy traces of the MongoDB database. These four types of logs are described below:
1. System Log
The system log is very important in mongdb data, it records MongoDB start and stop operations, and the server in the process of running any exception information, configuration system log is very simple, in the run Mongod time add a parameter logpath, you can set;
For example: Mongod-logpath= '/data/db/log/server.log '-logappend.
2. Journal Log
The JOURANL log adds additional reliability assurance to MongoDB by pre-writing the redo log. When this feature is turned on, data updates are written to the journal Log, regularly committed (currently every 100ms), and then the changes are made in the official data. The journal function of starting the database is very simple, just specify the journal parameter after Mongod;
Open mode: mongod-journal
3. Oplog Master-Slave log
MongoDB's highly available replication strategy has one called replica Sets.replicaset the replication process has one server acting as the primary server, and one or more acting from the server, the master service writes the update to a local collection, which records the update operations that occur on the primary server. and distribute these operations to the slave server. This log is capped Collection. Use the following command to configure
mongod-oplogsize=1024 Unit is M
4. Slow query log
The slow query records the operation statement that the execution time exceeds the set time threshold. The slow query log is useful for discovering statements that have a performance problem, and it is recommended that you turn on this feature and often analyze the contents of the log.
To configure this feature, you only need to set the profile parameter at Mongod boot time. For example, if you want to record more than 5s of operations, you can use the following statement:
Mongod--profile=1--slowms=5
Log system for "Monogdb" MongoDB