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

时间:2009-09-16 04:47:00

标签: java logging

当我得到一个新的记录器时,它总是将级别设置为INFO,但是文档告知否则(null),因此我打开了代码。文档和代码不匹配。我把它放在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();
}

1 个答案:

答案 0 :(得分:1)

在Logger Javadoc中看看这个:

  

每个记录器都有一个与其关联的“级别”。这反映了此记录器关心的最低级别。如果Logger的级别设置为null,则其有效级别将从其父级继承,而父级可以从其父级递归获取它,依此类推在树上。

在LogManager Javadoc中:根记录器的级别设置为Level.INFO

但我同意Logger Javadoc应该更清楚。