use of org.apache.logging.log4j.core.Appender in project logging-log4j2 by apache.
the class Log4j1ConfigurationFactoryTest method testDailyRollingFileAppender.
private void testDailyRollingFileAppender(final String configResource, final String name, final String filePattern) throws URISyntaxException {
final Configuration configuration = getConfiguration(configResource);
final Appender appender = configuration.getAppender(name);
assertNotNull(appender);
assertEquals(name, appender.getName());
assertTrue(appender.getClass().getName(), appender instanceof RollingFileAppender);
final RollingFileAppender rfa = (RollingFileAppender) appender;
assertEquals("target/hadoop.log", rfa.getFileName());
assertEquals(filePattern, rfa.getFilePattern());
final TriggeringPolicy triggeringPolicy = rfa.getTriggeringPolicy();
assertNotNull(triggeringPolicy);
assertTrue(triggeringPolicy.getClass().getName(), triggeringPolicy instanceof CompositeTriggeringPolicy);
final CompositeTriggeringPolicy ctp = (CompositeTriggeringPolicy) triggeringPolicy;
final TriggeringPolicy[] triggeringPolicies = ctp.getTriggeringPolicies();
assertEquals(1, triggeringPolicies.length);
final TriggeringPolicy tp = triggeringPolicies[0];
assertTrue(tp.getClass().getName(), tp instanceof TimeBasedTriggeringPolicy);
final TimeBasedTriggeringPolicy tbtp = (TimeBasedTriggeringPolicy) tp;
assertEquals(1, tbtp.getInterval());
final RolloverStrategy rolloverStrategy = rfa.getManager().getRolloverStrategy();
assertTrue(rolloverStrategy.getClass().getName(), rolloverStrategy instanceof DefaultRolloverStrategy);
final DefaultRolloverStrategy drs = (DefaultRolloverStrategy) rolloverStrategy;
assertEquals(Integer.MAX_VALUE, drs.getMaxIndex());
configuration.start();
configuration.stop();
}
use of org.apache.logging.log4j.core.Appender in project logging-log4j2 by apache.
the class Log4j1ConfigurationFactoryTest method testNullAppender.
@Test
public void testNullAppender() throws Exception {
final Configuration configuration = getConfiguration("config-1.2/log4j-NullAppender.properties");
final Appender appender = configuration.getAppender("NullAppender");
assertNotNull(appender);
assertEquals("NullAppender", appender.getName());
assertTrue(appender.getClass().getName(), appender instanceof NullAppender);
}
use of org.apache.logging.log4j.core.Appender in project logging-log4j2 by apache.
the class AbstractJpaAppenderTest method tearDown.
public void tearDown() throws SQLException {
final LoggerContext context = LoggerContext.getContext(false);
try {
final Appender appender = context.getConfiguration().getAppender("databaseAppender");
assertNotNull("The appender should not be null.", appender);
assertTrue("The appender should be a JpaAppender.", appender instanceof JpaAppender);
((JpaAppender) appender).getManager().close();
} finally {
System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
context.reconfigure();
StatusLogger.getLogger().reset();
try (Statement statement = this.connection.createStatement()) {
statement.execute("SHUTDOWN");
}
this.connection.close();
}
}
use of org.apache.logging.log4j.core.Appender in project logging-log4j2 by apache.
the class SyslogAppenderTestBase method removeAppenders.
protected void removeAppenders() {
final Map<String, Appender> map = root.getAppenders();
for (final Map.Entry<String, Appender> entry : map.entrySet()) {
final Appender app = entry.getValue();
root.removeAppender(app);
app.stop();
}
}
use of org.apache.logging.log4j.core.Appender in project logging-log4j2 by apache.
the class SocketAppenderTest method removeAndStopAppenders.
void removeAndStopAppenders() {
final Map<String, Appender> map = logger.getAppenders();
for (final Map.Entry<String, Appender> entry : map.entrySet()) {
final Appender appender = entry.getValue();
logger.removeAppender(appender);
appender.stop();
}
}
Aggregations