添加 log4j 環境apache
pom.xmlapi
<!-- 12.log4j 下面三個-->
<dependency>
<groupId>org.bgee.log4jdbc-log4j2</groupId>
<artifactId>log4jdbc-log4j2-jdbc4.1</artifactId>
<version>1.16</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.13</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.13</version>
</dependency>mybatis
導入日誌文件app
舊版本:學習
新版本:將內容寫入到磁盤位置,待優化(學習):佔時沒有解決 按類別寫入不一樣文件中 或 按日期寫入不一樣文件優化
#日誌級別有:OFF、FATAL、ERROR、WARN、INFO、DEBUG、TRACE、ALL log4j.rootLogger=ALL,Console,debug,BLUEJAY,RollingFile # MyBatis logging configuration... log4j.logger.org.mybatis.example.BlogMapper=TRACE # Console output... log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n #每小時生成一個日誌文件 log4j.appender.RollingFile=org.apache.log4j.DailyRollingFileAppender log4j.appender.RollingFile.Threshold=ALL log4j.appender.RollingFile.file=D:/logs/log.log log4j.appender.RollingFile.DatePattern='_'yyyyMMdd_HH'.txt' log4j.appender.RollingFile.layout=org.apache.log4j.PatternLayout log4j.appender.RollingFile.layout.ConversionPattern=[%p][%d{yyyy-MM-dd HH\:mm\:ss,SSS}][%l]%m%n log4j.appender.R.MaxFileSize=1GB log4j.appender.R.MaxBackupIndex=10