org.apache.log4j.rolling.TimeBasedRollingPolicy Java Examples
The following examples show how to use
org.apache.log4j.rolling.TimeBasedRollingPolicy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoggerBuilder.java From jforgame with Apache License 2.0 | 7 votes |
private static Logger build(String name) { Logger logger = Logger.getLogger(name); logger.removeAllAppenders(); logger.setLevel(Level.INFO); logger.setAdditivity(false); RollingFileAppender appender = new RollingFileAppender(); PatternLayout layout = new PatternLayout(); String conversionPatten = "[%d] %p %t %c - %m%n"; layout.setConversionPattern(conversionPatten); appender.setLayout(layout); appender.setEncoding("utf-8"); appender.setAppend(true); TimeBasedRollingPolicy policy = new TimeBasedRollingPolicy(); String fp = LoggerBuilder.LOG_PATH + name + "/" + name + ".log.%d{yyyy-MM-dd}"; policy.setFileNamePattern(fp); appender.setRollingPolicy(policy); appender.activateOptions(); logger.addAppender(appender); container.put(name,logger); return logger; }
Example #2
Source File: Util.java From celos with Apache License 2.0 | 6 votes |
public static void setupLogging(File logDir) { System.getProperties().setProperty("log4j.defaultInitOverride", "true"); RollingFileAppender appender = new RollingFileAppender(); appender.setFile(new File(logDir, "celos.log").getAbsolutePath()); appender.setAppend(true); TimeBasedRollingPolicy rollingPolicy = new TimeBasedRollingPolicy(); rollingPolicy.setFileNamePattern(new File(logDir, "celos-%d{yyyy-MM-dd}.log").getAbsolutePath()); appender.setRollingPolicy(rollingPolicy); PatternLayout patternLayout = new PatternLayout(); patternLayout.setConversionPattern("[%d{YYYY-MM-dd HH:mm:ss.SSS}] %-5p: %m%n"); appender.setLayout(patternLayout); appender.activateOptions(); Logger.getRootLogger().addAppender(appender); Logger.getRootLogger().setLevel(Level.INFO); }
Example #3
Source File: MetricsUploadPolicy.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
/** * Instantiates a new metrics upload policy. */ public MetricsUploadPolicy() { this.tbrp = new TimeBasedRollingPolicy(); }
Example #4
Source File: MetricsUploadPolicy.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
/** * Instantiates a new metrics upload policy. */ public MetricsUploadPolicy() { this.tbrp = new TimeBasedRollingPolicy(); }