Java 类org.apache.logging.log4j.core.impl.DefaultLogEventFactory 实例源码

项目:logging-log4j2    文件:LogEventFactoryTest.java   
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            System.setProperty(Constants.LOG4J_LOG_EVENT_FACTORY, TestLogEventFactory.class.getName());
            resetLogEventFactory(new TestLogEventFactory());
            try {
                base.evaluate();
            } finally {
                System.clearProperty(Constants.LOG4J_LOG_EVENT_FACTORY);
                resetLogEventFactory(new DefaultLogEventFactory());
            }
        }

        private void resetLogEventFactory(final LogEventFactory logEventFactory) throws IllegalAccessException {
            final Field field = FieldUtils.getField(LoggerConfig.class, "LOG_EVENT_FACTORY", true);
            FieldUtils.removeFinalModifier(field, true);
            FieldUtils.writeStaticField(field, logEventFactory, false);
        }
    };
}
项目:log4j2-elasticsearch    文件:AppenderRefFailoverPolicy.java   
/**
 * Extension point - let's allow to customize e.g.: LogEvent type or any other param
 *
 * @param failedPayload payload to be handled
 */
protected void doDeliver(String failedPayload) {
    appenderControl.callAppender(DefaultLogEventFactory.getInstance().createEvent(appenderRef.getRef(),
            null,
            getClass().getName(),
            appenderRef.getLevel(),
            new SimpleMessage(failedPayload),
            null,
            null));
}
项目:log4j2-elasticsearch    文件:ElasticsearchAppenderTest.java   
private LogEvent createTestLogEvent() {
    return DefaultLogEventFactory.getInstance().createEvent("testLogger",
            null,
            getClass().getName(),
            Level.INFO,
            new SimpleMessage("testMessage"),
            null,
            null);

}
项目:logging-log4j2    文件:RoutesScriptAppenderTest.java   
@Test
public void testRoutingAppenderRoutes() {
    final RoutingAppender routingAppender = getRoutingAppender();
    Assert.assertEquals(expectBindingEntries, routingAppender.getDefaultRouteScript() != null);
    Assert.assertEquals(expectBindingEntries, routingAppender.getDefaultRoute() != null);
    final Routes routes = routingAppender.getRoutes();
    Assert.assertNotNull(routes);
    Assert.assertNotNull(routes.getPatternScript());
    final LogEvent logEvent = DefaultLogEventFactory.getInstance().createEvent("", null, "", Level.ERROR, null,
            null, null);
    Assert.assertEquals("Service2", routes.getPattern(logEvent, new ConcurrentHashMap<>()));
}
项目:logging-log4j2    文件:AbstractStringLayout.java   
private DefaultLogEventFactory getLogEventFactory() {
    return DefaultLogEventFactory.getInstance();
}