zoukankan      html  css  js  c++  java
  • Java 日志寻址介绍

    一般使用logger的方式为

       private Logger logger = LoggerFactory.getLogger(MybatisStartTest.class);
    

      

    进入getLogger

        public static Logger getLogger(Class<?> clazz) {
            Logger logger = getLogger(clazz.getName());
            if(DETECT_LOGGER_NAME_MISMATCH) {
                Class<?> autoComputedCallingClass = Util.getCallingClass();
                if(autoComputedCallingClass != null && nonMatchingClasses(clazz, autoComputedCallingClass)) {
                    Util.report(String.format("Detected logger name mismatch. Given name: "%s"; computed name: "%s".", new Object[]{logger.getName(), autoComputedCallingClass.getName()}));
                    Util.report("See http://www.slf4j.org/codes.html#loggerNameMismatch for an explanation");
                }
            }
    
            return logger;
        }
    

     

    1、进入getLogger(clazz.getName());

        public static Logger getLogger(String name) {
            ILoggerFactory iLoggerFactory = getILoggerFactory();
            return iLoggerFactory.getLogger(name);
        }
    

      

    2、进入getILoggerFactory

    3、进入performInitialization方法

    4、   进入bind方法

        7. 如果存在多个日志框架打印提示及选择

    5、然后进入findPossibleStaticLoggerBinderPathSet方法。获得StaticLoggerBinder所在jar包路径

    6、将路径增加到staticLoggerBinderPathSet集合中。

    这个就是log的寻址过程。

    8、StaticLoggerBinder 这个类存在于logback中,通过这个类获得日志工厂再得实现。

  • 相关阅读:
    Coding 账户与 本地 Git 客户端的配置
    leetcode_sort-list
    leetcode_insertion-sort-list
    leetcode_move-zeroes
    search-insert-position
    leetcode_remove-nth-node-from-end-of-list
    leetcode_queue-reconstruction-by-height
    leetcode_valid-parentheses
    leetcode_swap-nodes-in-pairs
    20201115-东北师范大学-助教-周总结-第9次
  • 原文地址:https://www.cnblogs.com/linlf03/p/12450619.html
Copyright © 2011-2022 走看看