Package org.apache.logging.log4j.core

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


    @SuppressWarnings("unchecked")
    public void start() {
        final Map<String, Appender<?>> map = config.getAppenders();
        for (final AppenderRef ref : appenderRefs) {
            final String name = ref.getRef();
            final Appender appender = map.get(name);
            if (appender != null) {
                appenders.put(name, new AppenderControl(appender, ref.getLevel(), null));
            } else {
                LOGGER.error("Appender " + ref + " cannot be located. Reference ignored");
            }
View Full Code Here


    }

    protected void removeAppenders() {
        final Map<String,Appender> map = root.getAppenders();
        for (final Map.Entry<String, Appender> entry : map.entrySet()) {
            final Appender app = entry.getValue();
            root.removeAppender(app);
            app.stop();
        }
    }
View Full Code Here

        assertNotNull("No configuration", config);
        assertEquals("Incorrect Configuration.", CONFIG_NAME, config.getName());
        final Map<String, Appender> map = config.getAppenders();
        assertNotNull("Appenders map should not be null.", map);
        assertTrue("Appenders map should not be empty.", map.size() > 0);
        Appender app = null;
        for (final Map.Entry<String, Appender> entry: map.entrySet()) {
            if (entry.getKey().equals("List2")) {
                app = entry.getValue();
                break;
            }
        }
        assertNotNull("No ListAppender named List2", app);
        final Layout<? extends Serializable> layout = app.getLayout();
        assertNotNull("Appender List2 does not have a Layout", layout);
        assertTrue("Appender List2 is not configured with a PatternLayout", layout instanceof PatternLayout);
        final String pattern = ((PatternLayout) layout).getConversionPattern();
        assertNotNull("No conversion pattern for List2 PatternLayout", pattern);
        assertFalse("Environment variable was not substituted", pattern.startsWith("${env:PATH}"));
View Full Code Here

    @After
    public void teardown() {
        final Map<String,Appender> map = root.getAppenders();
        for (final Map.Entry<String, Appender> entry : map.entrySet()) {
            final Appender app = entry.getValue();
            root.removeAppender(app);
            app.stop();
        }
    }
View Full Code Here

    @After
    public void teardown() {
        final Map<String,Appender> map = root.getAppenders();
        for (final Map.Entry<String, Appender> entry : map.entrySet()) {
            final Appender app = entry.getValue();
            root.removeAppender(app);
            app.stop();
        }
    }
View Full Code Here

    @After
    public void tearDown() {
        final Map<String, Appender> map = root.getAppenders();
        for (final Map.Entry<String, Appender> entry : map.entrySet()) {
            final Appender app = entry.getValue();
            root.removeAppender(app);
            app.stop();
        }
    }
View Full Code Here

        final Filter filter = iter.next();
        assertTrue(filter instanceof ThreadContextMapFilter);
        final Map<String, Appender<?>> appenders = l.getAppenders();
        assertNotNull(appenders);
        assertTrue("number of appenders = " + appenders.size(), appenders.size() == 1);
        final Appender a = appenders.get("STDOUT");
        assertNotNull(a);
        assertEquals(a.getName(), "STDOUT");
    }
View Full Code Here

        final Logger logger = LogManager.getLogger(MapFilterTest.class);
        final Map<String, String> eventMap = new HashMap<String, String>();
        eventMap.put("eventId", "Login");
        logger.debug(new MapMessage(eventMap));
        final Map<String,Appender<?>> appenders = config.getAppenders();
        final Appender app = appenders.get("LIST");
        assertNotNull("No List appender", app);
        @SuppressWarnings("unchecked")
        final List<String> msgs = ((ListAppender<String>) app).getMessages();
        assertNotNull("No messages", msgs);
        assertTrue("No messages", msgs.size() > 0);
View Full Code Here

    @After
    public void tearDown() throws SQLException {
        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
        try {
            final Map<String, Appender> list = context.getConfiguration().getAppenders();
            final Appender appender = list.get("databaseAppender");
            assertNotNull("The appender should not be null.", appender);
            assertTrue("The appender should be a JDBCAppender.", appender instanceof JDBCAppender);
            ((JDBCAppender) appender).getManager().release();
        } finally {
            System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
View Full Code Here

    @After
    public void teardown() {
        Map<String,Appender> map = root.getAppenders();
        for (Map.Entry<String, Appender> entry : map.entrySet()) {
            Appender app = entry.getValue();
            root.removeAppender(app);
            app.stop();
        }
        tcpCount = 0;
        udpCount = 0;
    }
View Full Code Here

TOP

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

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.