Package org.apache.logging.log4j.core

Examples of org.apache.logging.log4j.core.Layout


     * Constructor to create the default configuration.
     */
    public DefaultConfiguration() {

        setName(DEFAULT_NAME);
        final Layout layout = PatternLayout.createLayout("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n",
            null, null, null);
        final Appender appender = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT", "Console", "false",
            "true");
        appender.start();
        addAppender(appender);
View Full Code Here


            }
        }
    }

    public synchronized void append(LogEvent event) {
        Layout layout = getLayout();
        if (layout == null) {
            events.add(event);
        } else if (layout instanceof SerializedLayout) {
            byte[] header = layout.getHeader();
            byte[] content = layout.format(event);
            byte[] record = new byte[header.length + content.length];
            System.arraycopy(header, 0, record, 0, header.length);
            System.arraycopy(content, 0, record, header.length, content.length);
            data.add(record);
        } else {
            write(layout.format(event));
        }
    }
View Full Code Here

    }

    @Override
    public void stop() {
        super.stop();
        Layout layout = getLayout();
        if (layout != null) {
            byte[] bytes = layout.getFooter();
            if (bytes != null) {
                write(bytes);
            }
        }
    }
View Full Code Here

    }

    @Test
    public void testClassName() {
        Category category = Category.getInstance("TestCategory");
        Layout layout = PatternLayout.createLayout("%d %p %C{1.} [%t] %m%n", null, null, null);
        ListAppender appender = new ListAppender("List2", null, layout, false, false);
        appender.start();
        category.setAdditivity(false);
        category.getLogger().addAppender(appender);
        category.error("Test Message");
View Full Code Here

     * Constructor to create the default configuration.
     */
    public DefaultConfiguration() {

        setName(DEFAULT_NAME);
        Layout layout = PatternLayout.createLayout("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n",
            null, null, null);
        Appender appender = ConsoleAppender.createAppender(layout, null, "SYSTEM_OUT", "Console", "true");
        appender.start();
        addAppender(appender);
        LoggerConfig root = getRootLogger();
View Full Code Here

        }
        verifyFile(count * processes);
    }

    private static void writer(boolean lock, int count, String name) throws Exception {
        Layout layout = PatternLayout.createLayout(PatternLayout.SIMPLE_CONVERSION_PATTERN, null, null, null);
        FileAppender app = FileAppender.createAppender(FILENAME, "true", Boolean.toString(lock), "test", "false",
            "false", "false", layout, null);
        Thread t = Thread.currentThread();
        app.start();
        assertTrue("Appender did not start", app.isStarted());
View Full Code Here

            }
        }
    }

    public synchronized void append(LogEvent event) {
        Layout layout = getLayout();
        if (layout == null) {
            events.add(event);
        } else if (layout instanceof SerializedLayout) {
            byte[] header = layout.getHeader();
            byte[] content = layout.format(event);
            byte[] record = new byte[header.length + content.length];
            System.arraycopy(header, 0, record, 0, header.length);
            System.arraycopy(content, 0, record, header.length, content.length);
            data.add(record);
        } else {
            write(layout.format(event));
        }
    }
View Full Code Here

        }
    }

    public void stop() {
        super.stop();
        Layout layout = getLayout();
        if (layout != null) {
            byte[] bytes = layout.getFooter();
            if (bytes != null) {
                write(bytes);
            }
        }
    }
View Full Code Here

    private static final String LINE_SEP = System.getProperty("line.separator");

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

    }

    @Test
    public void testClassName() {
        Category category = Category.getInstance("TestCategory");
        Layout layout = PatternLayout.createLayout("%d %p %C{1.} [%t] %m%n", null, null, null);
        ListAppender appender = new ListAppender("List2", null, layout, false, false);
        appender.start();
        category.setAdditivity(false);
        category.getLogger().addAppender(appender);
        category.error("Test Message");
View Full Code Here

TOP

Related Classes of org.apache.logging.log4j.core.Layout

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.