Java Code Examples for org.apache.log4j.RollingFileAppender#setMaxFileSize()

The following examples show how to use org.apache.log4j.RollingFileAppender#setMaxFileSize() . 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: LoggerFactory.java    From development with Apache License 2.0 5 votes vote down vote up
private static void initAppenders() throws IOException {
    systemLogAppender = new RollingFileAppender(getLayout(), logFilePath
            + File.separatorChar + "system.log");
    accessLogAppender = new RollingFileAppender(getLayout(), logFilePath
            + File.separatorChar + "access.log");
    auditLogAppender = new RollingFileAppender(getLayout(), logFilePath
            + File.separatorChar + "audit.log");
    reverseProxyLogAppender = new RollingFileAppender(getLayout(),
            logFilePath + File.separatorChar + "reverseproxy.log");

    // setting the max backup index and file size
    systemLogAppender.setMaxBackupIndex(MAX_BACKUP_INDEX);
    systemLogAppender.setMaxFileSize(MAX_FILE_SIZE);
    systemLogAppender.setName(systemLogAppenderName);

    accessLogAppender.setMaxBackupIndex(MAX_BACKUP_INDEX);
    accessLogAppender.setMaxFileSize(MAX_FILE_SIZE);
    accessLogAppender.setName(accessLogAppenderName);

    auditLogAppender.setMaxBackupIndex(MAX_BACKUP_INDEX);
    auditLogAppender.setMaxFileSize(MAX_FILE_SIZE);
    auditLogAppender.setName(auditLogAppenderName);

    reverseProxyLogAppender.setMaxBackupIndex(MAX_BACKUP_INDEX);
    reverseProxyLogAppender.setMaxFileSize(MAX_FILE_SIZE);
    reverseProxyLogAppender.setName(reverseProxyLogAppenderName);
}
 
Example 2
Source File: LoggingConfigurator.java    From selenium-grid-extensions with Apache License 2.0 5 votes vote down vote up
private void installFileAppender(String logFilename) {
    RollingFileAppender file = new RollingFileAppender();
    file.setName("FileAppender");
    file.setThreshold(logLevel);
    file.setFile(new File(logFilename).getAbsolutePath());
    file.setMaxFileSize(MAX_FILE_SIZE);
    file.setMaxBackupIndex(MAX_BACKUPS);
    file.setLayout(new PatternLayout(PATTERN));
    file.setAppend(true);
    file.activateOptions();

    Logger.getRootLogger().addAppender(file);
}
 
Example 3
Source File: HtmlLogFile.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private static WriterAppender createAppender(File logFile)
		throws IOException {
	HTMLLayout layout = new HTMLLayout();
	RollingFileAppender app = new RollingFileAppender(layout,
			logFile.getAbsolutePath(), true);
	app.setMaxFileSize("3MB");
	app.setMaxBackupIndex(3);
	return app;
}