public static Logger GetLogger (String name) usage
1. Initializes the log object with the specified class when logging output, you can print out the class of log information, as follows: Logger Logger = Loggerfactory.getlogger (com.
User.class);
Logger.debug ("User Information"); Will print out: com. User: 2. See source code: The GetLogger method in Loggerfactory returns an instance of a static binding named after name, which is typically named after the class in which the logger instance is located, such as through the class name.
Class.getname () obtained.
public static Logger GetLogger (String name) {iloggerfactory iloggerfactory = Getiloggerfactory ();
return Iloggerfactory.getlogger (name);
Iloggerfactory interface instances are bound loggerfactory internally at compile time, only one public Logger GetLogger (String name) method in this interface, returning the appropriate instance based on the parameter name
Look at this getiloggerfactory () method. public static Iloggerfactory Getiloggerfactory () {if (initialization_state = = uninitialized) {initialization_s
TATE = ongoing_initialization;
Performinitialization (); Switch (initialization_state) {case Successful_initialization:return Staticloggerbinder.getsingleton
(). Getloggerfactory ();
Case Nop_fallback_initialization:return Nop_fallback_factory; Case Failed_initialization:
throw new IllegalStateException (unsuccessful_init_msg);
Case Ongoing_initialization://Support re-entrant behavior.
also http://bugzilla.slf4j.org/show_bug.cgi?id=106 return temp_factory;
} throw new IllegalStateException ("Unreachable Code");
This is an instance of the return iloggerfactory used to fetch the GetLogger method. In the logger interface, the method of logging output is specified, and the output log information can be seen in the console according to the corresponding parameters.