简体   繁体   English

java.util.logger构造函数描述错误或javadoc错误?

[英]java.util.logger constructor description bug or javadoc error?

When I got a new logger it always had the level set to INFO but the documentation told otherwise (null), Hence I opened the code. 当我得到一个新的记录器时,它总是将级别设置为INFO,但是文档中则相反(为空),因此我打开了代码。 The documentation and the code doesnt match. 文档和代码不匹配。 I am putting it on stackoverflow for others dont have to struggle 我把它放在stackoverflow上,其他人不必费劲

    /**
 * Protected method to construct a logger for a named subsystem.
 * <p>
 * The logger will be initially configured with a null Level
 * and with useParentHandlers true.
 *
 * @param   name    A name for the logger.  This should
 *              be a dot-separated name and should normally
 *              be based on the package name or class name
 *              of the subsystem, such as java.net
 *              or javax.swing.  It may be null for anonymous Loggers.
 * @param   resourceBundleName  name of ResourceBundle to be used for localizing
 *              messages for this logger.  May be null if none
 *              of the messages require localization.
 * @throws MissingResourceException if the ResourceBundleName is non-null and
 *         no corresponding resource can be found.
 */
protected Logger(String name, String resourceBundleName) {
if (resourceBundleName != null) {
    // Note: we may get a MissingResourceException here.
    setupResourceInfo(resourceBundleName);
}
this.name = name;
levelValue = Level.INFO.intValue();
}

Look at this, in Logger Javadoc : 在Logger Javadoc中看一下:

Each Logger has a "Level" associated with it. 每个记录器都有一个与之关联的“级别”。 This reflects a minimum Level that this logger cares about. 这反映了该记录器关心的最低级别。 If a Logger's level is set to null, then its effective level is inherited from its parent, which may in turn obtain it recursively from its parent, and so on up the tree. 如果Logger的级别设置为null,则其有效级别将从其父级继承,而后者又可以从其父级递归获取它,依此类推。

And in LogManager Javadoc : The root logger's level is set to Level.INFO 并且在LogManager Javadoc中:将根记录器的级别设置为Level.INFO。

But I'm agree that the Logger Javadoc should be clearer. 但是我同意Logger Javadoc应该更加清晰。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM