?????????Java??ó?????д?????log4j???????????????????????????

??????Sun????JDK???д?????????????????????????????????????????????????????????JDK?????????????????????????????????????????????????????????????????

?????????????log4j???????????μ??log4j????????????????????????????logback???e???????logback?????2006????????汾1.0??2011??11?·???????

????logback????????????????log4j???????log4j???????????????????汾1.0?????????????????????????????°汾??1.0.1????????????????汾?????С???????????????????logback??????????????????????汾????????????????????????????????

????logback?log4j???????????????????г???????

????·????????

????·????????????????????

????·????????????filter??

????·???????鵵????????

????·??????????????Java????jar??????????

????·????????????鵵???

?????????????????????log4j?????logback???????????????Maven POM??????????????????????

    <dependency>    
        <groupId>ch.qos.logback</groupId>    
        <artifactId>logback-classic</artifactId>    
        <version>1.0.0</version>    
     </dependency>

??????????????????????facace??slf4j?????????????project?????

??????slf4j????“Hello World”?????????????

    package demo;  
    import org.slf4j.Logger;  
    import org.slf4j.LoggerFactory;  
    public class HelloWorld {  
      public static void main(String[] args) {  
       Logger log = LoggerFactory.getLogger(HelloWorld.class);  
       log.info("Hello World");  
      }  
    }

?????????????????????д????????????????????????????

?????????????log4j?????????log4j.xml????logback????logback.xml????????????????????logback-test.xml??

??????Maven project??logback.xml??????????$PROJECT_HOME/src/main/resources???С?logback-test.xml??????????$PROJECT_HOME/src/test/resources???С????????????????????????д??

    <configuration>  
     <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">  
      <!-- encoders are assigned the type  
         ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->  
      <encoder>  
       <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>  
      </encoder>  
     </appender>  
     <root level="debug">  
      <appender-ref ref="STDOUT" />  
     </root>  
    </configuration>