• java-log4j配置


    引入依赖:

    <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.14</version>
            </dependency>

    配置log4j.properties:

    log4j.rootLogger=debug,stdout,DEBUG,ERROR 
    
    #console
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender 
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 
    log4j.appender.stdout.layout.ConversionPattern= [%d{yyyy-MM-dd HH:mm:ss a}]:%p %l%m%n
    
    #debug 按大小及个数打印
    log4j.logger.DEBUG=DEBUG
    log4j.appender.DEBUG=org.apache.log4j.RollingFileAppender
    log4j.appender.DEBUG.File=${catalina.home}/logs/ftptool_debug.log
    log4j.appender.DEBUG.Threshold=DEBUG
    log4j.appender.DEBUG.MaxFileSize=20MB
    log4j.appender.DEBUG.MaxBackupIndex=10
    log4j.appender.DEBUG.layout=org.apache.log4j.PatternLayout 
    log4j.appender.DEBUG.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [ Class:%c >> Method: %l ]%n%p:%m%n
    
    #error 按日期打印
    log4j.logger.ERROR=ERROR
    log4j.appender.ERROR=org.apache.log4j.DailyRollingFileAppender 
    log4j.appender.ERROR.File=${catalina.home}/logs/ftptool_error.log
    log4j.appender.ERROR.DatePattern='.'yyyy-MM-dd
    log4j.appender.ERROR.Threshold=ERROR 
    log4j.appender.ERROR.Append=true 
    log4j.appender.ERROR.layout=org.apache.log4j.PatternLayout 
    log4j.appender.ERROR.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n
  • 相关阅读:
    Android进阶篇系统缓存(一)
    Android提高篇自定义Menu(二)
    Android进阶篇Canvas Bitmap
    Android进阶篇分析伪3D旋转
    Android进阶篇捕获app错误信息
    Android进阶篇Service和广播
    Android进阶篇清除WebView的缓存
    Android进阶篇Parcelable包裹类
    Android进阶篇GestureDetector初探
    Android进阶篇下拉刷新
  • 原文地址:https://www.cnblogs.com/lijianda/p/11857661.html
Copyright © 2020-2023  润新知