use of org.apache.log4j.rolling.SizeBasedTriggeringPolicy in project tray by qzind.
the class PrintSocketServer method setupFileLogging.
public static void setupFileLogging() {
FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
rollingPolicy.setFileNamePattern(SystemUtilities.getDataDirectory() + File.separator + Constants.LOG_FILE + ".log.%i");
rollingPolicy.setMaxIndex(Constants.LOG_ROTATIONS);
SizeBasedTriggeringPolicy triggeringPolicy = new SizeBasedTriggeringPolicy(Constants.LOG_SIZE);
RollingFileAppender fileAppender = new RollingFileAppender();
fileAppender.setLayout(new PatternLayout("%d{ISO8601} [%p] %m%n"));
fileAppender.setThreshold(Level.DEBUG);
fileAppender.setFile(SystemUtilities.getDataDirectory() + File.separator + Constants.LOG_FILE + ".log");
fileAppender.setRollingPolicy(rollingPolicy);
fileAppender.setTriggeringPolicy(triggeringPolicy);
fileAppender.setEncoding("UTF-8");
fileAppender.setImmediateFlush(true);
fileAppender.activateOptions();
org.apache.log4j.Logger.getRootLogger().addAppender(fileAppender);
}
Aggregations