Package org.apache.logging.log4j.core.impl

Examples of org.apache.logging.log4j.core.impl.Log4jLogEvent


            "false", "false", layout, null, "false", null, null);
        final Thread t = Thread.currentThread();
        app.start();
        assertTrue("Appender did not start", app.isStarted());
        for (int i=0; i < count; ++i) {
            final LogEvent event = new Log4jLogEvent("TestLogger", null, FileAppenderTest.class.getName(), Level.INFO,
                new SimpleMessage("Test"), null, null, null, name, null, System.currentTimeMillis());
            try {
                app.append(event);
                t.sleep(25)// Give up control long enough for another thread/process to occasionally do something.
            } catch (final Exception ex) {
View Full Code Here


    public void testFollow() {
        final PrintStream ps = System.out;
        final Layout<String> layout = PatternLayout.createLayout(null, null, null, null);
        final ConsoleAppender<String> app = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT", "Console", "true", "false");
        app.start();
        final LogEvent event = new Log4jLogEvent("TestLogger", null, ConsoleAppenderTest.class.getName(), Level.INFO,
            new SimpleMessage("Test"), null);

        assertTrue("Appender did not start", app.isStarted());
        System.setOut(new PrintStream(baos));
        app.append(event);
View Full Code Here

    @Test
    public void testAppender() {
        final Layout<String> layout = PatternLayout.createLayout(null, null, null, null);
        final InMemoryAppender<String> app = new InMemoryAppender<String>("test", layout, null, false);
        final LogEvent event = new Log4jLogEvent("TestLogger", null, OutputStreamAppenderTest.class.getName(), Level.INFO,
            new SimpleMessage("Test"), null);
        app.start();
        assertTrue("Appender did not start", app.isStarted());
        app.append(event);
        final String msg = app.toString();
View Full Code Here

                    }
                }
            }
        }
        final MapMessage message = ((MapMessage) msg).newInstance(newMap);
        return new Log4jLogEvent(source.getLoggerName(), source.getMarker(), source.getFQCN(), source.getLevel(),
            message, source.getThrown(), source.getContextMap(), source.getContextStack(), source.getThreadName(),
            source.getSource(), source.getMillis());
    }
View Full Code Here

            final Property prop = entry.getKey();
            props.put(prop.getName(), entry.getValue() ?
                config.getSubst().replace(prop.getValue()) : prop.getValue());
        }

        return new Log4jLogEvent(source.getLoggerName(), source.getMarker(), source.getFQCN(), source.getLevel(),
            source.getMessage(), source.getThrown(), props, source.getContextStack(), source.getThreadName(),
            source.getSource(), source.getMillis());
    }
View Full Code Here

        assertNotNull(formatters);
        final Map<String, String> mdc = new HashMap<String, String>();
        mdc.put("loginId", "Fred");
        final Throwable t = new Throwable();
        final StackTraceElement[] elements = t.getStackTrace();
        final LogEvent event = new Log4jLogEvent("org.apache.logging.log4j.PatternParserTest", MarkerManager.getMarker("TEST"),
            Logger.class.getName(), Level.INFO, new SimpleMessage("Hello, world"), null,
            mdc, null, "Thread1", elements[0], System.currentTimeMillis());
        final StringBuilder buf = new StringBuilder();
        for (final PatternFormatter formatter : formatters) {
            formatter.format(event, buf);
View Full Code Here

    private void testNestedPatternHighlight(final Level level, final String expectedStart) {
        final List<PatternFormatter> formatters = parser.parse(nestedPatternHighlight);
        assertNotNull(formatters);
        final Throwable t = new Throwable();
        final StackTraceElement[] stackTraceElement = t.getStackTrace();
        final LogEvent event = new Log4jLogEvent("org.apache.logging.log4j.PatternParserTest",
                MarkerManager.getMarker("TEST"), Logger.class.getName(), level, new SimpleMessage("Hello, world"),
                null, null, null, "Thread1", /*stackTraceElement[0]*/null, System.currentTimeMillis());
        final StringBuilder buf = new StringBuilder();
        for (final PatternFormatter formatter : formatters) {
            formatter.format(event, buf);
View Full Code Here

    @Test
    public void testLocation() {
        final Timer timer = new Timer("LogEvent", LOOP_COUNT);
        timer.start();
        for (int i = 0; i < LOOP_COUNT; ++i) {
            final LogEvent event1 = new Log4jLogEvent(this.getClass().getName(), null,
                "org.apache.logging.log4j.core.impl.Log4jLogEvent",
                Level.INFO, new SimpleMessage("Hello, world!"), null);
            final StackTraceElement element = event1.getSource();
        }
        timer.stop();
        System.out.println(timer.toString());
    }
View Full Code Here

    }

    @GenerateMicroBenchmark
    public void testNoException(final BlackHole bh) {
        final Throwable t = null;
        final Log4jLogEvent event = new Log4jLogEvent("a.b.c", null, "a.b.c", Level.INFO, MESSAGE, t);
        bh.consume(event);
    }
View Full Code Here

    }

    @GenerateMicroBenchmark
    public void testException(final BlackHole bh) {
        final Throwable t = ERROR;
        final Log4jLogEvent event = new Log4jLogEvent("a.b.c", null, "a.b.c", Level.INFO, MESSAGE, t);
        bh.consume(event);
    }
View Full Code Here

TOP

Related Classes of org.apache.logging.log4j.core.impl.Log4jLogEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.