Get the App
SLTechnology News&Howtos  ›  Database  › 

What is the use of log files in MongoDB database

Shulou Source: shulou.com Published: 2022-05-31 19:51:50 09月28日 Update

This article mainly introduces what the log files of MongoDB database are used for. The introduction in this article is very detailed and has certain reference value. Interested friends must read it!

Format of log messages

[]

For example:

2014-11-03T18:28:32.450-0500 I NETWORK [initandlisten] waiting for connections on port 27017

log message severity level

level

level description

F

Fatal

E

Error

W

Warning

I

Informational, for Verbosity Level of 0

D

Debug, for All Verbosity Levels > 0

Information Category

Journal category

English

virtools categorized

login information

ACCESS

Log in to access relevant information, such as login authentication.

command information

COMMAND

The database executes command-related information, such as queries.

control management information

CONTROL

Records control management-related information, such as database initialization.

FTDC Information

FTDC(full-time diagnostic data )

Data information is detected throughout the process, such as server status statistics.

index information

INDEX

Index-related information, such as information on the creation process of the index.

network information

NETWORK

Network related information, such as network connection information.

query information

QUERY

Query related information, such as query plan information.

Copy Set Information

REPL

Information related to replica set, such as replica set initial process, heartbeat, rollback, etc.

slice information

SHARDING

Fragment-related information, such as mongos startup information

store information

STORAGE

Store related information, such as information to brush storage layer data to disk.

restore information

RECOVERY

Restore activity-related information

log information

JOURNAL

Log related information

write operation information

WRITE

Write information about the operation, such as the update command.

query log level of detail

MongoDB divides logs into levels of detail 0 - 5

1. 0 is the default level for MongoDB logs, which contain Informational class information.

2. Debug levels 1 - 5 log all complete requests from the client.

Command to query log level of detail.

db.getLogComponents()

Modify Log Level of Detail

There are two ways to modify log verbosity.

The first is to set the logComponentVerbosity parameter to modify it.

Another point to note is that log classification can be further refined,

For example, set systemLog to 1 as a whole, where query and storage are set to 2, and journal is set to 1.

The specific commands to modify are:

db.adminCommand( { setParameter: 1, logComponentVerbosity: { verbosity: 1, query: { verbosity: 2 }, storage: { verbosity: 2, journal: { verbosity: 1 } } }} )

The second method, modified by db.setLogLevel().

This approach is mostly directed at modifying a single log category. Another point to note is that we sometimes see a log level of-1 through db.getLogComponents(), which means the same level as its parent category.

For example, if we set the log verbosity level of the query category to the log verbosity level of the parent class (systemLog), we can execute the following command:

db.setLogLevel(-1, "query")

The above two methods are modified, so can initialization be configured? In fact, it is possible, we only need to add the corresponding parameters in the initial configuration file, and will not expand here.

The above is "MongoDB database log file what to use" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Tags: Information logs levels data commands levels queries databases subitems categories files copies methods categories indexes networks content parameters articles procedures Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS Huawei Redmi Apple