LoggerFactory.java 文件源码

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

项目:opencron 作者:
public static Logger getLogger(@SuppressWarnings("rawtypes") Class clazz) {

        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        URL url = loader.getResource("log4j.properties");
        String path;
        if (url==null) {
            String currPath = LoggerFactory.class.getProtectionDomain().getCodeSource().getLocation().getFile();
            File file = new File(currPath);
            path = file.getParentFile().getParentFile() + "/conf/log4j.properties";
            if (!new File(path).exists()) {
                throw new ExceptionInInitializerError("[opencron] error: can not found log4j.properties...");
            }
        }else {
            path = url.getPath();
        }
        PropertyConfigurator.configure(path);
        return org.slf4j.LoggerFactory.getLogger(clazz);
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号