Loggerfactory.getlogger (String name) usage __logger

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.