在这种情况下,我使用的是oshi
sysinfo 库和 spring boot。
我尝试使用将com.github.oshi
记录器设置为的 log4j2.xml 文件,INFO
但它无法关闭以下DEBUG
级别的消息。
...
04:33:57.687 [Thread-3] DEBUG oshi.util.FileUtil - Reading file /sys/devices/system/cpu/cpu10/cpufreq/scaling_cur_freq
04:33:57.687 [Thread-3] DEBUG oshi.util.FileUtil - Reading file /sys/devices/system/cpu/cpu10/cpufreq/scaling_cur_freq
/sys/devices/system/cpu/cpu13/cpufreq/scaling_cur_freq
04:33:57.707 [Thread-3] DEBUG oshi.util.FileUtil - Reading file
...
log4j2.xml 中的以下设置不起作用:
<category name="oshi">
<priority value="OFF"/>
</category>
<Loggers>
<!-- avoid duplicated logs with additivity=false -->
<Logger name="oshi" level="info" additivity="false">
<AppenderRef ref="LogToRollingFile"/>
</Logger>
<Root level="info">
<AppenderRef ref="LogToConsole"/>
</Root>
</Loggers>
pom.xml
包含:
...
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
...