zoukankan      html  css  js  c++  java
  • 引入Log4j

    1. pom文件添加依赖

    <!-- log start -->
        <dependency>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
          <version>${log4j.version}</version>
        </dependency>
        <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
          <version>${slf4j.version}</version>
        </dependency>
        <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
          <version>${slf4j.version}</version>
        </dependency>
        <!-- log end -->

    2. 添加log4j.properties文件

    # DEBUG,INFO,WARN,ERROR,FATAL
    LOG_LEVEL=DEBUG
    
    log4j.rootLogger=${LOG_LEVEL},CONSOLE,FILE
    
    log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
    log4j.appender.CONSOLE.Encoding=utf-8
    log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
    #log4j.appender.CONSOLE.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss} %C{8}@(%F:%L):%m%n 
    log4j.appender.CONSOLE.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss} %C{1}@(%F:%L):%m%n
    
    log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.FILE.File=${catalina.base}/logs/quick4j.log
    log4j.appender.FILE.Encoding=utf-8
    log4j.appender.FILE.DatePattern='.'yyyy-MM-dd
    log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
    #log4j.appender.FILE.layout=org.apache.log4j.HTMLLayout
    log4j.appender.FILE.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss} %C{8}@(%F:%L):%m%n 
  • 相关阅读:
    modf()函数
    面向对象编程五大原则
    .Net网络资源
    整理CentOS常用命令
    在RHEL5上安装oracle10gLinux
    strchr()函数
    swab函数
    Strstr()函数
    tmpnam函数
    strdup ()函数
  • 原文地址:https://www.cnblogs.com/xpawn/p/7532482.html
Copyright © 2011-2022 走看看