slf4j + log4j 日志 使用
1.依赖(这依赖添加了slf4j和log4j)
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.30</version> </dependency>
2.配置log4j.properties文件,放在resources目录下
log4j.rootLogger=DEBUG,console,dailyFile log4j.additivity.org.apache=true #配置参考文章 https://blog.csdn.net/qq_41947226/article/details/79800296 # 控制台(console) log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.Threshold=DEBUG log4j.appender.console.ImmediateFlush=true log4j.appender.console.Target=System.out log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %m%n # 定期滚动日志文件(dailyFile) log4j.appender.dailyFile=org.apache.log4j.DailyRollingFileAppender log4j.appender.dailyFile.Threshold=DEBUG log4j.appender.dailyFile.ImmediateFlush=true log4j.appender.dailyFile.Append=true log4j.appender.dailyFile.File=D:/logs/log.log log4j.appender.dailyFile.DatePattern=‘.‘yyyy-MM-dd log4j.appender.dailyFile.layout=org.apache.log4j.PatternLayout log4j.appender.dailyFile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%p] %m%n
3.使用即可
相关推荐
chw0 2020-11-04
sdaq 2020-07-26
MrLiar 2020-07-07
sdaq 2020-06-16
丨Fanny丨Cri 2020-06-13
CXC0 2020-06-08
MrLiar 2020-06-04
丨Fanny丨Cri 2020-06-03
丨Fanny丨Cri 2020-05-17
JavaWinner 2020-05-10
JavaWinner 2020-05-04
CXC0 2020-04-20
CXC0 2020-04-10
丨Fanny丨Cri 2020-02-18
MrLiar 2020-02-16
CXC0 2020-02-09