Search in sources :

Example 1 with RollingFileAppender

use of org.apache.log4j.RollingFileAppender in project hadoop by apache.

the class TestFsck method setupAuditLogs.

/** Sets up log4j logger for auditlogs. */
private void setupAuditLogs() throws IOException {
    File file = new File(AUDITLOG_FILE);
    if (file.exists()) {
        file.delete();
    }
    Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();
    logger.setLevel(Level.INFO);
    PatternLayout layout = new PatternLayout("%m%n");
    RollingFileAppender appender = new RollingFileAppender(layout, AUDITLOG_FILE);
    logger.addAppender(appender);
}
Also used : Log4JLogger(org.apache.commons.logging.impl.Log4JLogger) RollingFileAppender(org.apache.log4j.RollingFileAppender) PatternLayout(org.apache.log4j.PatternLayout) Logger(org.apache.log4j.Logger) Log4JLogger(org.apache.commons.logging.impl.Log4JLogger) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 2 with RollingFileAppender

use of org.apache.log4j.RollingFileAppender in project hadoop by apache.

the class TestAuditLogs method configureAuditLogs.

private void configureAuditLogs() throws IOException {
    // Shutdown the LogManager to release all logger open file handles.
    // Unfortunately, Apache commons logging library does not provide
    // means to release underlying loggers. For additional info look up
    // commons library FAQ.
    LogManager.shutdown();
    File file = new File(auditLogFile);
    if (file.exists()) {
        assertTrue(file.delete());
    }
    Logger logger = ((Log4JLogger) FSNamesystem.auditLog).getLogger();
    // disable logging while the cluster startup preps files
    logger.setLevel(Level.OFF);
    PatternLayout layout = new PatternLayout("%m%n");
    RollingFileAppender appender = new RollingFileAppender(layout, auditLogFile);
    logger.addAppender(appender);
}
Also used : Log4JLogger(org.apache.commons.logging.impl.Log4JLogger) RollingFileAppender(org.apache.log4j.RollingFileAppender) PatternLayout(org.apache.log4j.PatternLayout) Log4JLogger(org.apache.commons.logging.impl.Log4JLogger) Logger(org.apache.log4j.Logger) File(java.io.File)

Example 3 with RollingFileAppender

use of org.apache.log4j.RollingFileAppender in project gocd by gocd.

the class LoggingHelper method createFileAppender.

private static Appender createFileAppender(String logOutputFilename) {
    RollingFileAppender appender;
    try {
        appender = new RollingFileAppender(LOG4J_PATTERN, logFilePath(logOutputFilename), true);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    appender.setMaxBackupIndex(4);
    appender.setMaxFileSize("5000KB");
    return appender;
}
Also used : RollingFileAppender(org.apache.log4j.RollingFileAppender) IOException(java.io.IOException)

Example 4 with RollingFileAppender

use of org.apache.log4j.RollingFileAppender in project gocd by gocd.

the class DefaultPluginLoggingService method getAppender.

private FileAppender getAppender(String pluginId) {
    try {
        String logDirectory = getCurrentLogDirectory();
        File pluginLogFileLocation = new File(logDirectory, pluginLogFileName(pluginId));
        return new RollingFileAppender(new PatternLayout("%d{ISO8601} %5p [%t] %c{1}:%L - %m%n"), pluginLogFileLocation.getPath(), true);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : RollingFileAppender(org.apache.log4j.RollingFileAppender) PatternLayout(org.apache.log4j.PatternLayout) IOException(java.io.IOException) File(java.io.File)

Example 5 with RollingFileAppender

use of org.apache.log4j.RollingFileAppender in project apex-core by apache.

the class LogFileInformationTest method testImmediateFlushOff.

@Test
public void testImmediateFlushOff() {
    RollingFileAppender rfa = (RollingFileAppender) Logger.getRootLogger().getAppender(APPENDER_NAME);
    rfa.setImmediateFlush(false);
    Logger.getRootLogger().addAppender(rfa);
    LoggerUtil.initializeLogger();
    Assert.assertNull(LoggerUtil.getLogFileInformation());
    rfa.setImmediateFlush(true);
}
Also used : RollingFileAppender(org.apache.log4j.RollingFileAppender) Test(org.junit.Test)

Aggregations

RollingFileAppender (org.apache.log4j.RollingFileAppender)16 PatternLayout (org.apache.log4j.PatternLayout)8 Logger (org.apache.log4j.Logger)6 File (java.io.File)4 IOException (java.io.IOException)4 IgniteLogger (org.apache.ignite.IgniteLogger)3 GridTestLog4jLogger (org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger)3 ConsoleAppender (org.apache.log4j.ConsoleAppender)3 Log4JLogger (org.apache.commons.logging.impl.Log4JLogger)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 Appender (org.apache.log4j.Appender)2 LevelRangeFilter (org.apache.log4j.varia.LevelRangeFilter)2 Test (org.junit.Test)2 RandomAccessFile (java.io.RandomAccessFile)1 NullLogger (org.apache.ignite.logger.NullLogger)1 FileAppender (org.apache.log4j.FileAppender)1 BeforeClass (org.junit.BeforeClass)1 Logger (org.slf4j.Logger)1