java类org.slf4j.impl.JDK14LoggerAdapter的实例源码

ScoreboardStats.java 文件源码 项目:ScoreboardStats 阅读 24 收藏 0 点赞 0 评论 0
private static Logger createLoggerFromJDK(java.util.logging.Logger parent) {
    try {
        parent.setLevel(Level.ALL);

        Class<JDK14LoggerAdapter> adapterClass = JDK14LoggerAdapter.class;
        Constructor<JDK14LoggerAdapter> cons = adapterClass.getDeclaredConstructor(java.util.logging.Logger.class);
        cons.setAccessible(true);
        return cons.newInstance(parent);
    } catch (ReflectiveOperationException reflectEx) {
        parent.log(Level.WARNING, "Cannot create slf4j logging adapter", reflectEx);
        parent.log(Level.WARNING, "Creating logger instance manually...");
        return LoggerFactory.getLogger(parent.getName());
    }
}
SLF4J_JavaUtilLoggingCollector.java 文件源码 项目:TestLogCollectors 阅读 24 收藏 0 点赞 0 评论 0
public static JavaUtilLoggingCollector create(Object o) {
    JDK14LoggerAdapter adapter = (JDK14LoggerAdapter) o;
    Logger logger = Logger.getLogger(adapter.getName());
    return new JavaUtilLoggingCollector(logger);
}


问题


面经


文章

微信
公众号

扫码关注公众号