db.setLogLevel()
On this page本页内容
Definition定义
db.setLogLevel()
-
Sets a single verbosity level for log messages.为日志消息设置单个详细级别。db.setLogLevel()
has the following form:具有以下形式:db.setLogLevel(<level>, <component>)
db.setLogLevel()
takes the following parameters:采用以下参数:Parameter参数Type类型Description描述level
int The log verbosity level.日志详细级别。
The verbosity level can range from详细程度级别可以在0
to5
:0
到5
之间:0
is the MongoDB's default log verbosity level, to include Informational messages.是MongoDB的默认日志详细级别,以包括信息消息。1
to5
increases the verbosity level to include Debug messages.1
到5
增加了详细级别以包括调试消息。
To inherit the verbosity level of the component's parent, you can also specify要继承组件父级的详细级别,还可以指定-1
.-1
。component
string Optional.可选的。The name of the component for which to specify the log verbosity level.要为其指定日志详细级别的组件的名称。The component name corresponds to the组件名称对应于相应<name>
from the correspondingsystemLog.component.<name>.verbosity
setting:systemLog.component.<name>.verbosity
设置中的<name>
:accessControl
command
control
ftdc
geo
index
network
query
replication
replication.election
replication.heartbeats
replication.initialSync
replication.rollback
recovery
sharding
storage
storage.journal
transaction
write
Omit to specify the default verbosity level for all components.忽略为所有组件指定默认详细级别。
Behavior行为
db.setLogLevel()
sets a single verbosity level. 设置单个详细级别。To set multiple verbosity levels in a single operation, use either the 要在单个操作中设置多个详细级别,请使用setParameter
command to set the logComponentVerbosity
parameter. setParameter
命令设置logComponentVerbosity
参数。You can also specify the verbosity settings in the configuration file. See Configure Log Verbosity Levels for examples.您也可以在配置文件中指定详细程度设置。有关示例,请参阅配置日志详细级别。
Starting in version 4.2, MongoDB includes the Debug verbosity level (1-5) in the log messages. 从4.2版本开始,MongoDB在日志消息中包含调试详细级别(1-5)。For example, if the verbosity level is 2, MongoDB logs 例如,如果详细级别为2,MongoDB将记录D2
. D2
。In previous versions, MongoDB log messages only specified 在以前的版本中,MongoDB日志消息只为调试级别指定了D
for Debug level.D
。
Examples实例
Set Default Verbosity Level设置默认详细级别
Omit the 省略<component>
parameter to set the default verbosity for all components; i.e. the systemLog.verbosity
setting. The operation sets the default verbosity to 1
:<component>
参数以设置所有组件的默认详细程度;即systemLog.verbosity
设置。该操作将默认详细程度设置为1
:
db.setLogLevel(1)
Set Verbosity Level for a Component设置组件的详细级别
Specify the 指定<component>
parameter to set the verbosity for the component. <component>
参数以设置组件的详细程度。The following operation updates the 以下操作将systemLog.component.storage.journal.verbosity
to 2
:systemLog.component.storage.journal.verbosity
更新为2
:
db.setLogLevel(2, "storage.journal" )