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);
}
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);
}
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;
}
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);
}
}
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);
}
Aggregations