zoukankan      html  css  js  c++  java
  • Java log4j

                <dependency>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
                <version>1.2</version>
                </dependency>
                <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-simple</artifactId>
                    <version>1.7.25</version>
                    <scope>test</scope>
                </dependency>
    log4j.rootLogger=INFO, stdout
    
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
    
    log4j.tracer.infoLogger = INFO, stdout, A1
    log4j.additivity.infoLogger = false
    log4j.appender.A1 = org.apache.log4j.DailyRollingFileAppender
    log4j.appender.A1.File = ${catalina.home}/logs/A-Info.log
    log4j.appender.A1.DatePattern = '.'yyyy-MM-dd
    log4j.appender.A1.Threshold = INFO
    log4j.appender.A1.Append = true
    log4j.appender.A1.layout = org.apache.log4j.PatternLayout
    log4j.appender.A1.layout.ConversionPattern = %d %p [%t] %c %m%n
    
    log4j.tracer.errorLogger = ERROR, stdout, A2
    log4j.additivity.errorLogger = false
    log4j.appender.A2 = org.apache.log4j.DailyRollingFileAppender
    log4j.appender.A2.File = ${catalina.home}/logs/A-Error.log
    log4j.appender.A2.DatePattern = '.'yyyy-MM-dd
    log4j.appender.A2.Threshold = ERROR
    log4j.appender.A2.Append = true
    log4j.appender.A2.layout = org.apache.log4j.PatternLayout
    log4j.appender.A2.layout.ConversionPattern = %d %p [%t] %c %m%n
    
    log4j.tracer.Job = INFO, ERROR, stdout, A3
    log4j.additivity.Job = false
    log4j.appender.A3 = org.apache.log4j.DailyRollingFileAppender
    log4j.appender.A3.File = ${catalina.home}/logs/A-Job.log
    log4j.appender.A3.DatePattern = '.'yyyy-MM-dd
    log4j.appender.A3.Threshold = INFO, ERROR
    log4j.appender.A3.Append = true
    log4j.appender.A3.layout = org.apache.log4j.PatternLayout
    log4j.appender.A3.layout.ConversionPattern = %d %p [%t] %c %m%n
    package org.rx;
    
    import org.slf4j.LoggerFactory;
    
    public final class Logger {
        private static final org.slf4j.Logger log1 = LoggerFactory.getLogger("infoLogger"),
                log2 = LoggerFactory.getLogger("errorLogger");
        //private static final Log log1 = LogFactory.getLog("infoLogger"), log2 = LogFactory.getLog("errorLogger");
    
        public static void debug(String format, Object... args) {
            String msg = args.length == 0 ? format : String.format(format, args);
            System.out.println(msg);
            log1.debug(msg);
        }
    
        public static void info(String format, Object... args) {
            String msg = args.length == 0 ? format : String.format(format, args);
            log1.info(msg + System.lineSeparator());
        }
    
        public static void error(Throwable ex, String format, Object... args) {
            String msg = args.length == 0 ? format : String.format(format, args);
            log2.error(String.format("%s%s %s", System.lineSeparator(), ex.getMessage(), msg), ex);
        }
    }
  • 相关阅读:
    CUDA 函数前缀与存储器前缀讨论
    VC++控制台程序中使用定时器
    C++中的RTTI
    C/C++ 时间转换与表示
    [转]winsock和winsock2冲突
    自然归并排序 c++ (原创)
    关于CC++运行时库的多线程版本的工作记录
    关于sizeof(原)
    结构体最后的长度为0或1数组的作用(转载)
    CUDA中常见的错误:the launch timed out and was treminated.
  • 原文地址:https://www.cnblogs.com/Googler/p/7552315.html
Copyright © 2011-2022 走看看