Java?????????Logback??SLF4J
???????????? ???????[ 2013/2/22 10:23:42 ] ????????
?????????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>
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11