ClassLogger.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:ProjectAres 作者:
public static ClassLogger get(@Nullable Logger parent, Class<?> klass, @Nullable String instanceKey) {
    if(parent == null) {
        parent = Logger.getLogger("");
    }

    ClassLogger logger = find(parent, klass, instanceKey);
    if(logger == null) {
        logger = new ClassLogger(parent, klass, instanceKey);
        // TODO: call addLogger from the constructuor, when it's no longer public
        final LogManager logManager = LogManager.getLogManager();
        if(logManager.addLogger(logger)) {
            // addLogger will set the parent, so we have to set it back again
            logger.setParent(parent);
        } else {
            // Logger was created by another thread
            logger = find(parent, klass, instanceKey);
            if(logger == null) {
                throw new IllegalStateException("Failed to register logger " + getName(klass, instanceKey));
            }
        }
    }

    return logger;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号