本次Log4j源码研读的入口,是从 logger = Logger.getLogger("test"),这个方法调用开始,我们看看下边是时序图:
下边是对上述时序图的解读:
我们actioner通过调用Logger.getLogger("test")方法的时候,会提交的Logger类的静态方法getLogger,这个静态方法源码如下:
public static Logger getLogger(String name) {
return LogManager.getLogger(name);
}
我们可以知道,这个时候,我们调用到了LogManager的静态方法getLogger(name),源码如下:
/**
Retrieve the appropriate {@link Logger} instance.
*/
public static Logger getLogger(String name) {
// Delegate the actual manufacturing of the logger to the logger repository.