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); } }