Java 类org.apache.logging.log4j.status.StatusData 实例源码

项目:log4j2    文件:StatusLoggerAdmin.java   
@Override
public String[] getStatusDataHistory() {
    final List<StatusData> data = getStatusData();
    final String[] result = new String[data.size()];
    for (int i = 0; i < result.length; i++) {
        result[i] = data.get(i).getFormattedStatus();
    }
    return result;
}
项目:log4j2    文件:StatusLoggerAdmin.java   
@Override
public void log(final StatusData data) {
    final Notification notifMsg = new Notification(NOTIF_TYPE_MESSAGE,
            getObjectName(), nextSeqNo(), now(), data.getFormattedStatus());
    sendNotification(notifMsg);

    final Notification notifData = new Notification(NOTIF_TYPE_DATA,
            getObjectName(), nextSeqNo(), now());
    notifData.setUserData(data);
    sendNotification(notifData);
}
项目:logging-log4j2    文件:StatusLoggerAdmin.java   
@Override
public String[] getStatusDataHistory() {
    final List<StatusData> data = getStatusData();
    final String[] result = new String[data.size()];
    for (int i = 0; i < result.length; i++) {
        result[i] = data.get(i).getFormattedStatus();
    }
    return result;
}
项目:logging-log4j2    文件:StatusLoggerAdmin.java   
@Override
public void log(final StatusData data) {
    final Notification notifMsg = new Notification(NOTIF_TYPE_MESSAGE, getObjectName(), nextSeqNo(), nowMillis(),
            data.getFormattedStatus());
    sendNotification(notifMsg);

    final Notification notifData = new Notification(NOTIF_TYPE_DATA, getObjectName(), nextSeqNo(), nowMillis());
    notifData.setUserData(data);
    sendNotification(notifData);
}
项目:logging-log4j2    文件:LoggersPluginTest.java   
@Test
public void testEmptyAttribute() throws Exception {
    final Logger logger = LogManager.getLogger();
    logger.info("Test");
    final StatusData data = StatusLogger.getLogger().getStatusData().get(0);
    //System.out.println(data.getFormattedStatus());

    assertEquals(Level.ERROR, data.getLevel());
    assertTrue(data.getMessage().getFormattedMessage().contains("multiple root loggers"));
}
项目:logging-log4j2    文件:HttpAppenderTest.java   
@Test
public void testAppendErrorIgnore() throws Exception {
    wireMockRule.stubFor(post(urlEqualTo("/test/log4j/"))
        .willReturn(FAILURE_RESPONSE));

    StatusLogger.getLogger().registerListener(new StatusListener() {
        @Override
        public void log(final StatusData data) {
            error = data;
        }

        @Override
        public Level getStatusLevel() {
            return Level.ERROR;
        }

        @Override
        public void close() throws IOException { }
    });

    error = null;

    final Appender appender = HttpAppender.newBuilder()
        .withName("Http")
        .withLayout(JsonLayout.createDefaultLayout())
        .setConfiguration(ctx.getConfiguration())
        .setUrl(new URL("http://localhost:" + wireMockRule.port() + "/test/log4j/"))
        .build();
    appender.append(createLogEvent());

    wireMockRule.verify(postRequestedFor(urlEqualTo("/test/log4j/"))
        .withHeader("Host", containing("localhost"))
        .withHeader("Content-Type", containing("application/json"))
        .withRequestBody(containing("\"message\" : \"" + LOG_MESSAGE + "\"")));

    assertNotNull(error);
    assertEquals(Level.ERROR, error.getLevel());
    assertEquals("Unable to send HTTP in appender [Http]", error.getMessage().toString());
}
项目:logging-log4j2    文件:OutputStreamManagerTest.java   
@Test
public void narrow() throws Exception {
    final Logger logger = LogManager.getLogger(OutputStreamManagerTest.class);
    logger.info("test");
    final List<StatusData> statusData = StatusLogger.getLogger().getStatusData();
    StatusData data = statusData.get(0);
    if (data.getMessage().getFormattedMessage().contains("WindowsAnsiOutputStream")) {
        data = statusData.get(1);
    }
    assertEquals(Level.ERROR, data.getLevel());
    assertEquals("Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender for element RollingRandomAccessFile",
            data.getMessage().getFormattedMessage());
    assertEquals("org.apache.logging.log4j.core.config.ConfigurationException: Configuration has multiple incompatible Appenders pointing to the same resource 'target/multiIncompatibleAppender.log'",
            data.getThrowable().toString());
}
项目:elasticsearch_my    文件:ESTestCase.java   
@Override
public void log(StatusData data) {
    synchronized (statusData) {
        statusData.add(data);
    }
}
项目:log4j2    文件:StatusLoggerAdmin.java   
@Override
public List<StatusData> getStatusData() {
    return StatusLogger.getLogger().getStatusData();
}
项目:logging-log4j2    文件:StatusLoggerAdmin.java   
@Override
public List<StatusData> getStatusData() {
    return StatusLogger.getLogger().getStatusData();
}
项目:log4j2    文件:StatusLoggerAdminMBean.java   
/**
 * Returns a list with the most recent {@code StatusData} objects in the
 * status history. The list has up to 200 entries by default but the length
 * can be configured with system property {@code "log4j2.status.entries"}.
 * <p>
 * Note that the returned objects may contain {@code Throwable}s from
 * external libraries.
 *
 * JMX clients calling this method must be prepared to deal with the errors
 * that occur if they do not have the class definition for such
 * {@code Throwable}s in their classpath.
 *
 * @return the most recent messages logged by the {@code StatusLogger}.
 */
List<StatusData> getStatusData();
项目:logging-log4j2    文件:StatusLoggerAdminMBean.java   
/**
 * Returns a list with the most recent {@code StatusData} objects in the
 * status history. The list has up to 200 entries by default but the length
 * can be configured with system property {@code "log4j2.status.entries"}.
 * <p>
 * Note that the returned objects may contain {@code Throwable}s from
 * external libraries.
 * </p>
 * <p>
 * JMX clients calling this method must be prepared to deal with the errors
 * that occur if they do not have the class definition for such
 * {@code Throwable}s in their classpath.
 * </p>
 *
 * @return the most recent messages logged by the {@code StatusLogger}.
 */
List<StatusData> getStatusData();