Logger
protected Logger(String name)Method Detail getLogger
public static Logger getLogger(String name)Retrieve a logger named according to the value of the name parameter. If the named logger already exists, then the existing instance will be returned. Otherwise, a new instance is created. 
By default, loggers do not have a set level but inherit it from their neareast ancestor with a set level. This is one of the central features of log4j.Parameters:
name - The name of the logger to retrieve.--------------------------------------------------------------------------------getLogger
public static Logger getLogger(Class clazz)Shorthand for getLogger(clazz.getName()).
Parameters:
clazz - The name of clazz will be used as the name of the logger to retrieve. See getLogger(String) for more detailed information.--------------------------------------------------------------------------------getRootLogger
public static Logger getRootLogger()Return the root logger for the current logger repository. 
The Logger.getName() method for the root logger always returns stirng value: "root". However, calling Logger.getLogger("root") does not retrieve the root logger but a logger just under root named "root". In other words, calling this method is the only way to retrieve the root logger.
--------------------------------------------------------------------------------getLogger
public static Logger getLogger(String name,
                               LoggerFactory factory)Like getLogger(String) except that the type of logger instantiated depends on the type returned by the LoggerFactory.makeNewLoggerInstance(java.lang.String) method of the factory parameter. 
This method is intended to be used by sub-classes.Parameters:
name - The name of the logger to retrieve.
factory - A LoggerFactory implementation that will actually create a new Instance.
Since: 
0.8.5

解决方案 »

  1.   

    在记录器层次的顶端是根记录器(Root Logger),注意两点:一是根记录器永远存在,二是不能通过名称获得。通过调用Logger类的静态方法public static Logger Logger.getRootLogger()获得根记录器,非根记录通过指定的名字(即将进行日志记录的类名)获得记录器:public static Logger Logger.getLogger(String name)或者public static Logger Logger.getLogger(Class clazz)获得(或者创建)一个named logger。后者相当于调用Logger.getLogger(clazz.getName())。
           在某对象中,用该对象所属的类为参数,调用Logger.getLogger(Class clazz)以获得logger被认为是目前所知的最理智的命名logger的方法。
           记录器logger的创建可以按照任意的顺序,即,父logger可以后于子logger被创建。log4j将自动维护logger的继承树。
      

  2.   

    昏倒没看到  OnlyFor_love  的跟贴,就结帖了,那就再开一贴吧。