java-Log Frame

Source: Internet
Author: User

a requirement material1 common-Logging2 jcl-over-slf4j3 slf4j-API4 logback-Classic. 5 spring-beans.4.15. Two simple process Org.springframework.web.context.ContextLoader.initWebApplicationContext-275Org.apache.commons.logging.Log Logger= Org.apache.commons.logging.LogFactory.getLog (Contextloader.class  ) Org.apache.commons.logging.LogFactory.getFactory ()                                                                    Org.apache.commons.logging.LogFactory.getCachedFactory () Org.apache.commons.logging.LogFactory.getConfigurationFile ( ) Org.apache.commons.logging.LogFactory.getSystemProper Ty () org.apache.commons.logging.LogFactory. getResourceAsStream () Org.apache.commons.logging.LogFac Tory.cachefactory () org.apache.commons.logging. Impl. Slf4jlogfactory.getinstance (ORG.SLF4J,  Logger Slf4jlogger=Org.slf4j.LoggerFactory.getLogger ( Org.slf4j.ILoggerFactory iloggerfactory= Org.slf4j.LoggerFactory.getILoggerFactory (                                                                                                                                             Org.slf4j.LoggerFactory.performInitialization (                                                                                                                                                        Org.slf4j.LoggerFactory.bind ( Org.slf4j.LoggerFactory.findPossibleStaticLoggerBinderPa                                                                                                                                                        Thset ()                                                                                                                                                       Org.slf4j.LoggerFactory.reportMultipleBindingAmbiguity () Staticloggerbinder.getsIngleton ();                                                                                                                                                      Reportactualbinding (Staticloggerbinderpathset);                                                                                                                                                                Emitsubstituteloggerwarning                                                                                                                                                                )                                                                                                                                     )returnOrg.slf4j.impl.StaticLoggerBinder.getSingleton (). Getloggerfactory ();                                                                                    );                                                                                                                                                                                                ); Org.apache.commons.logging.Log newinstance=NewOrg.apache.commons.logging.impl.SLF4JLocationAwareLog ((Locationawarelogger) slf4jlogger);                                                                                                                                                                                                  ) Three-core Apicommon-Logging.jar (I) org.apache.commons.logging.Log (A) org.apache.commons.logging.logfactoryjcl-over-Logging.jar (C) org.apache.commons.logging.impl.SLF4JLogFactoryextendsorg.apache.commons.logging.LogFactory (C) Org.apache.commons.logging.impl.SLF4JLocationAwareLogImplementsOrg.apache.commons.logging.Log slf4j-Api.jar (i) Org.slf4j.Logger (C) org.slf4j.LoggerFactory (i) org.slf4j.ILoggerFactory (i) Org.slf4j.spi.Locati OnawareloggerextendsOrg.slf4j.Logger Logback-Classic.jar (C) Ch.qos.logback.classic.LoggerContextextendsContextbaseImplementsorg.slf4j.ILoggerFactory (C) Org.slf4j.impl.StaticLoggerBinderImplementsOrg.slf4j.spi.LoggerFactoryBinder


(Wordy words)
As I said before, the main starting point for using SLF4J to write log statements in your code is to make your program independent of any particular log class library, depending on a particular class library that might need to use a different configuration than you already have, and cause more maintenance headaches. In addition to that, there is a slf4j API that makes me insist on using slf4j to abandon my long-cherished log4j, which is called the placeholder (place holder), which is represented in the code as "{}"Feature. Placeholder is a very similar to theStringOfformat()Method in the%sbecause it will be replaced at run time by a given actual string. This not only reduces the number of string connections in your code, but also saves the new string object. By using SLF4J, you can delay the creation of strings at run time, which means that only the required string objects are created. And if you've already used log4j, you're already familiar with the workaround for using the debug statement in the IF condition, but the slf4j placeholder is much more useful than this.

java-Log Frame

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.