slf4j + log4j 須要的依賴

正確的依賴

<!-- slf4j 依賴包 --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.25</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.25</version> </dependency>

 

#這個是本身項目中使用的一個配置,方便拿來直接使用。簡單的配置,若是想要添加詳細配置須要去找資料,看一下log4j的具體參數配,這裏暫時沒有。

log4j.rootLogger=info,consoleLog,logfile # Console output... log4j.appender.consoleLog=org.apache.log4j.ConsoleAppender log4j.appender.consoleLog.layout=org.apache.log4j.PatternLayout log4j.appender.consoleLog.layout.ConversionPattern=[%p]-%-d{HH:mm:ss}-%c{1} - %m%n # file output...error one day log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender log4j.appender.logfile.DatePattern='.'yyyy-MM-dd'.log' log4j.appender.logfile.File=${catalina.base}/jfinal_mac.log log4j.appender.logfile.Threshold = error log4j.appender.logfile.layout=org.apache.log4j.PatternLayout log4j.appender.logfile.layout.ConversionPattern= [%p]-%-d{HH:mm:ss}-%c{1} - %m%n # file output...info every hour log4j.appender.D = org.apache.log4j.DailyRollingFileAppender log4j.appender.D.DatePattern='.'yyyy-MM-dd-HH'.log' log4j.appender.D.File = ${catalina.base}/logs/jfinal_mac.txt log4j.appender.D.Append = true log4j.appender.D.Threshold = info log4j.appender.D.layout = org.apache.log4j.PatternLayout log4j.appender.D.layout.ConversionPattern = [%p]-%-d{HH\:mm\:ss}-%c{1} - %m%n

 

 

如下在配置時候出現的問題:apache

可能有的依賴版本不一樣,致使直接默認使用的式log4j2.xml  或  log4j2.json   json

啓動是出現過問題:  api

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'log4j2.debug' to show Log4j2 internal initialization logging.app

使用的依賴是一下的:spa

<!-- slf4j 依賴包 --><dependency>    <groupId>org.slf4j</groupId>    <artifactId>slf4j-api</artifactId>    <version>1.7.25</version></dependency><dependency>    <groupId>org.apache.logging.log4j</groupId>    <artifactId>log4j-slf4j-impl</artifactId>    <version>2.9.1</version></dependency><dependency>    <groupId>org.apache.logging.log4j</groupId>    <artifactId>log4j-api</artifactId>    <version>2.9.1</version></dependency><dependency>    <groupId>org.apache.logging.log4j</groupId>    <artifactId>log4j-core</artifactId>    <version>2.9.1</version></dependency>不太清楚這幾個依賴怎麼搭配,記錄一下,最上邊的是可使用的,複製直接使用就能夠了。
相關文章
相關標籤/搜索