Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of log files in MongoDB database

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report