本文整理了Java中org.apache.logging.log4j.core.Appender.isStarted()
方法的一些代码示例,展示了Appender.isStarted()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Appender.isStarted()
方法的具体详情如下:
包路径:org.apache.logging.log4j.core.Appender
类名称:Appender
方法名:isStarted
暂无
代码示例来源:origin: mulesoft/mule
@Override
public void run() {
contextConfigurer.update(context);
ArgumentCaptor<ConsoleAppender> appenderCaptor = ArgumentCaptor.forClass(ConsoleAppender.class);
verify(context.getConfiguration()).addAppender(appenderCaptor.capture());
Appender forcedConsoleAppender = appenderCaptor.getValue();
assertThat(forcedConsoleAppender, notNullValue());
assertThat(forcedConsoleAppender.getName(), equalTo(FORCED_CONSOLE_APPENDER_NAME));
assertThat(forcedConsoleAppender.isStarted(), is(true));
LoggerConfig rootLogger = ((AbstractConfiguration) context.getConfiguration()).getRootLogger();
verify(rootLogger).addAppender(forcedConsoleAppender, Level.ALL, null);
}
});
代码示例来源:origin: mulesoft/mule
@Test
public void perAppDefaultAppender() throws Exception {
when(context.isArtifactClassloader()).thenReturn(true);
when(context.getArtifactDescriptor().getDeploymentProperties()).thenReturn(empty());
contextConfigurer.update(context);
ArgumentCaptor<RollingFileAppender> appenderCaptor = ArgumentCaptor.forClass(RollingFileAppender.class);
verify(context.getConfiguration()).addAppender(appenderCaptor.capture());
Appender perAppAppender = appenderCaptor.getValue();
assertThat(perAppAppender, notNullValue());
assertThat(perAppAppender.getName(), equalTo(PER_APP_FILE_APPENDER_NAME));
assertThat(perAppAppender.isStarted(), is(true));
String filePattern = ClassUtils.getFieldValue(perAppAppender, FILE_PATTERN_PROPERTY, true);
String filePatternTemplate = filePattern.substring(filePattern.lastIndexOf('/') + 1);
String filePatternTemplateDateSuffix = filePatternTemplate.substring(filePatternTemplate.lastIndexOf('.') + 1);
assertThat(filePatternTemplateDateSuffix, equalTo(FILE_PATTERN_TEMPLATE_DATE_SECTION));
LoggerConfig rootLogger = context.getConfiguration().getRootLogger();
verify(rootLogger).addAppender(perAppAppender, Level.ALL, null);
}
代码示例来源:origin: ops4j/org.ops4j.pax.logging
private void ensureAppenderStarted() {
if (!appender.isStarted()) {
handleError("Attempted to append to non-started appender ");
}
}
代码示例来源:origin: kptfh/feign-reactive
@Before
public void before() {
appender = Mockito.mock(Appender.class);
when(appender.getName()).thenReturn("TestAppender");
when(appender.isStarted()).thenReturn(true);
getLoggerConfig().addAppender(appender, Level.ALL, null);
}
代码示例来源:origin: rfoltyns/log4j2-elasticsearch
@Test(expected = ConfigurationException.class)
public void throwsExceptionOnUnresolvedAppender() {
// given
Appender appender = mock(Appender.class);
when(appender.isStarted()).thenReturn(true);
Configuration configuration = mock(Configuration.class);
String testAppenderRef = "testAppenderRef";
when(configuration.getAppender(testAppenderRef)).thenReturn(null);
FailoverPolicy<String> failoverPolicy = createTestFailoverPolicy(testAppenderRef, configuration);
String failedMessage = "test failed message";
// when
failoverPolicy.deliver(failedMessage);
}
public static FailoverPolicy<String> createTestFailoverPolicy(String testAppenderRef, Configuration configuration) {
代码示例来源:origin: rfoltyns/log4j2-elasticsearch
@Test
public void deliversToAppenderRef() {
// given
Appender appender = mock(Appender.class);
when(appender.isStarted()).thenReturn(true);
Configuration configuration = mock(Configuration.class);
String testAppenderRef = "testAppenderRef";
when(configuration.getAppender(testAppenderRef)).thenReturn(appender);
FailoverPolicy<String> failoverPolicy = createTestFailoverPolicy(testAppenderRef, configuration);
String failedMessage = "test failed message";
// when
failoverPolicy.deliver(failedMessage);
// then
verify(appender, times(1)).append(any(LogEvent.class));
}
代码示例来源:origin: rfoltyns/log4j2-elasticsearch
@Test
public void resolvesAppenderRefOnlyOnce() {
// given
Appender appender = mock(Appender.class);
when(appender.isStarted()).thenReturn(true);
Configuration configuration = mock(Configuration.class);
String testAppenderRef = "testAppenderRef";
when(configuration.getAppender(testAppenderRef)).thenReturn(appender);
FailoverPolicy<String> failoverPolicy = createTestFailoverPolicy(testAppenderRef, configuration);
String failedMessage = "test failed message";
// when
failoverPolicy.deliver(failedMessage);
failoverPolicy.deliver(failedMessage);
// then
verify(configuration, times(1)).getAppender(anyString());
verify(appender, times(2)).append(any(LogEvent.class));
}
代码示例来源:origin: ops4j/org.ops4j.pax.logging
int appenderCount = 0;
for (int i = array.length - 1; i >= 0; --i) {
if (array[i].isStarted()) { // then stop remaining Appenders
if (array[i] instanceof LifeCycle2) {
((LifeCycle2) array[i]).stop(timeout, timeUnit);
内容来源于网络,如有侵权,请联系作者删除!