7.spring_boot log4j

七、spring_boot整合Log4j

  1. 找到第一个启动器

    <exclusions>
    	<!--排除logging-->
    	<exclusion>
    		<groupId>org.springframework.boot</groupId>
    		<artifactId>spring-boot-starter-logging</artifactId>
    	</exclusion>
    </exclusions>
    
  2. 添加依赖

    <!-- log4j. -->
    <dependency>
    	<groupId>org.springframework.boot</groupId>
    	<artifactId>spring-boot-starter-log4j</artifactId>
    	<version>	1.3.8.RELEASE</version>
    </dependency>
    
  3. 添加log4j.properties

    log4j.rootLogger=DEBUG,A1,DRF
    log4j.appender.A1=org.apache.log4j.ConsoleAppender
    log4j.appender.A1.layout=org.apache.log4j.PatternLayout
    log4j.appender.A1.layout.ConversionPattern=%d %5p [%F:%L] : %m%n
    
    log4j.appender.DRF=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.DRF.Threshold=DEBUG
    log4j.appender.DRF.DatePattern='.'yyyy-MM-dd
    log4j.appender.DRF.File=logs/pms.log
    log4j.appender.DRF.Append=true
    log4j.appender.DRF.layout=org.apache.log4j.PatternLayout
    log4j.appender.DRF.layout.ConversionPattern=[%-5p][%d{yyyyMMdd HH:mm:ss,SSS}][%C{1}:%L] %m%n
    
    log4j.logger.com.ibatis=DEBUG
    log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
    log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
    log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
    log4j.logger.java.sql.Connection=DEBUG
    log4j.logger.java.sql.Statement=DEBUG
    log4j.logger.java.sql.PreparedStatement=DEBUG
    

おすすめ

転載: blog.csdn.net/weixin_43285931/article/details/103409568