Log
Posted wenlin-gk
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Log相关的知识,希望对你有一定的参考价值。
jar包:
orgslf4jslf4j-api1.7.25slf4j-api-1.7.25.jar orgslf4jslf4j-log4j121.7.25slf4j-log4j12-1.7.25.jar log4jlog4j1.2.17log4j-1.2.17.jar
配置:
/test
/test/src/main/java
/test/src/main/java/test
/test/src/main/java/log4j.properties
/test/src/main/resources
/test/src/main/resources/git_add
/test/src/main/resources/log4j.properties
log4j.rootLogger=info, stdout #log4j.rootLogger=info, logfile ### console u65E5u5FD7 ### log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target = System.out log4j.appender.stdout.layout = org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern = %d %p [%c %L] - %m%n log4j.appender.logfile=org.apache.log4j.FileAppender log4j.appender.logfile.File=tmp/aidfs.log log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern= %d %p [%c %L] - %m%n
格式化输出:
import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class LineSeparator { private static Logger logger = LoggerFactory.getLogger(LineSeparator.class); public static void main(String[] args) { logger.info("{}, {}, {}", true, 1, "lin"); } }
以上是关于Log的主要内容,如果未能解决你的问题,请参考以下文章