Search in sources :

Example 11 with DailyRollingFileAppender

use of org.apache.log4j.DailyRollingFileAppender in project gerrit by GerritCodeReview.

the class SystemLog method createAppender.

public static Appender createAppender(Path logdir, String name, Layout layout, boolean rotate) {
    final FileAppender dst = rotate ? new DailyRollingFileAppender() : new FileAppender();
    dst.setName(name);
    dst.setLayout(layout);
    dst.setEncoding(UTF_8.name());
    dst.setFile(resolve(logdir).resolve(name).toString());
    dst.setImmediateFlush(true);
    dst.setAppend(true);
    dst.setErrorHandler(new DieErrorHandler());
    dst.activateOptions();
    dst.setErrorHandler(new OnlyOnceErrorHandler());
    return dst;
}
Also used : DailyRollingFileAppender(org.apache.log4j.DailyRollingFileAppender) FileAppender(org.apache.log4j.FileAppender) DailyRollingFileAppender(org.apache.log4j.DailyRollingFileAppender) OnlyOnceErrorHandler(org.apache.log4j.helpers.OnlyOnceErrorHandler)

Aggregations

DailyRollingFileAppender (org.apache.log4j.DailyRollingFileAppender)11 PatternLayout (org.apache.log4j.PatternLayout)6 IOException (java.io.IOException)5 File (java.io.File)4 Appender (org.apache.log4j.Appender)4 FileAppender (org.apache.log4j.FileAppender)3 Logger (org.apache.log4j.Logger)3 Layout (org.apache.log4j.Layout)2 OnlyOnceErrorHandler (org.apache.log4j.helpers.OnlyOnceErrorHandler)2 NullAppender (org.apache.log4j.varia.NullAppender)2 AbstractInternalLogger (org.jboss.netty.logging.AbstractInternalLogger)2 InternalLogger (org.jboss.netty.logging.InternalLogger)2 InternalLoggerFactory (org.jboss.netty.logging.InternalLoggerFactory)2 PrintWriter (java.io.PrintWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Field (java.lang.reflect.Field)1 SocketException (java.net.SocketException)1 Path (java.nio.file.Path)1 ExecutionException (java.util.concurrent.ExecutionException)1 ConsoleAppender (org.apache.log4j.ConsoleAppender)1