[英]Java logging level is ignored in properties file
I have the following logging.properties
file for java logging, which is a slightly modified version of the default logging.properties
file that comes with the JDK: 我有以下用于java日志记录的
logging.properties
文件,它是JDK附带的默认logging.properties
文件的略微修改版本:
handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
# Default global logging level.
# This specifies which kinds of events are logged across
# all loggers. For any given facility this global level
# can be overriden by a facility specific level
# Note that the ConsoleHandler also has a separate level
# setting to limit messages printed to the console.
.level = INFO
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.level=FINEST
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.level = CONFIG
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
The level settings for FileHandler
and ConsoleHandler
are ignored. FileHandler
和ConsoleHandler
的级别设置将被忽略。 They only work if I set global .level = FINEST
. 它们仅在我设置global
.level = FINEST
。 It seems, that .level
acts as global limit to what can be logged. 似乎
.level
充当可记录内容的全局限制。 From the description, however, I would have expected that the settings in FileHandler
and ConsoleHandler
override the global setting. 但是,根据描述,我希望
FileHandler
和ConsoleHandler
的设置会覆盖全局设置。
Do I need additional settings to configure? 是否需要其他设置进行配置?
PS: Java version is 1.8. PS:Java版本是1.8。
The Java Logging Overview will give you a breakdown of how the logging framework is setup. Java日志记录概述将向您详细介绍如何设置日志记录框架。
The line .level = FINEST
determines the level of the root logger. .level = FINEST
确定根记录程序的级别 。 Meaning that if you have log
calls in your code they will generate log records which will be published to the attached handers and possibly to parent handlers. 这意味着,如果您的代码中有
log
调用,它们将生成日志记录,这些日志记录将发布到附加的处理程序,甚至可能发布到父处理程序。
The java.util.logging.FileHandler.level=FINEST
line determines the lowest level that will be published to the output file. java.util.logging.FileHandler.level=FINEST
行确定将发布到输出文件的最低级别 。 For instance, java.util.logging.ConsoleHandler.level = CONFIG
will only publish records CONFIG and higher to the console. 例如,
java.util.logging.ConsoleHandler.level = CONFIG
只会将CONFIG及更高版本的记录发布到控制台。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.