如何在启动期间停止从登录node.conf的节点 [英] How to stop node from logging node.conf during startup
问题描述
如何停止节点在日志中打印node.conf?
How do I stop the node from printing the node.conf in the logs?
我知道我们可以更改日志记录级别,因为node.conf是在INFO级别打印的,但是我想尽可能避免这种情况,因为我仍然想要其他一些
I understand we can change the logging level since the node.conf is printed at INFO level, but I want to avoid that as much as possible since I still want some other information that is at INFO level to be printed out.
推荐答案
node.conf的内容
由 net.corda.node.services.config.ConfigHelper
类以 INFO
级别打印。为了防止 node.conf
的内容被打印到日志中,您必须指定一个自定义的日志记录配置,以便对 net进行配置。 corda.node.services.config.ConfigHelper
类,仅将 WARN
或更高级别的消息打印到日志中。
The contents of node.conf
are printed at INFO
level by the net.corda.node.services.config.ConfigHelper
class. To prevent the contents of node.conf
from being printed to the logs, you'd have to specify a custom logging configuration so that for the net.corda.node.services.config.ConfigHelper
class, only messages at WARN
or above should be printed to the logs.
为您的节点提供自定义Log4J2日志记录配置文件的过程已记录在此处。您需要:
The process for providing a custom Log4J2 logging configuration file for your node is documented here. You need to:
- 创建自定义日志文件(例如
test.xml
) - 启动节点时将节点指向自定义日志文件(例如
java -Dlog4j.configurationFile = test.xml -jar corda.jar
)
- Create the custom logging file (e.g.
test.xml
) - Point your node to the custom logging file when starting the node (e.g.
java -Dlog4j.configurationFile=test.xml -jar corda.jar
)
下面是一个示例 test.xml
,该示例阻止了 node.conf
被打印到日志中:
Here's an example test.xml
that prevents the contents of node.conf
being printed to the logs:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Properties>
<Property name="log-path">logs</Property>
<Property name="log-name">node-${hostName}</Property>
<Property name="archive">${log-path}/archive</Property>
</Properties>
<Appenders>
<Console name="Console-Appender" target="SYSTEM_OUT">
<PatternLayout pattern="%highlight{%level{length=1} %d{HH:mm:ss} %T %c{1}.%M - %msg%n}{INFO=white,WARN=red,FATAL=bright red blink}"/>
</Console>
<RollingFile name="RollingFile-Appender"
fileName="${log-path}/${log-name}.log"
filePattern="${archive}/${log-name}.%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout pattern="[%-5level] %d{ISO8601}{GMT+0} [%t] %c{1} - %msg%n"/>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="10MB"/>
</Policies>
<DefaultRolloverStrategy min="1" max="10">
<Delete basePath="${archive}" maxDepth="1">
<IfFileName glob="${log-name}*.log.gz"/>
<IfLastModified age="60d">
<IfAny>
<IfAccumulatedFileSize exceeds="10 GB"/>
</IfAny>
</IfLastModified>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="Console-Appender"/>
<AppenderRef ref="RollingFile-Appender"/>
</Root>
<Logger name="net.corda" level="error" additivity="false">
<AppenderRef ref="Console-Appender"/>
<AppenderRef ref="RollingFile-Appender"/>
</Logger>
<Logger name="net.corda.node.services.config.ConfigHelper" level="warn" additivity="false">
<AppenderRef ref="RollingFile-Appender"/>
</Logger>
</Loggers>
</Configuration>
请注意最后一个 Logger
块。我们指定来自 net.corda.node.services.config.ConfigHelper
的任何消息(例如 node.conf
)仅在它们达到 WARN
或更高级别时才打印。
Note the final Logger
block. We specify that any messages from net.corda.node.services.config.ConfigHelper
(e.g. the contents of node.conf
) should only be printed if they are at level WARN
or above.
这篇关于如何在启动期间停止从登录node.conf的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!