Package org.apache.logging.log4j.core

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


    private static final String CONFIG = "log4j-test1.xml";

    @BeforeClass
    public static void setUpClass() {
        System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
        context.getConfiguration();
    }
View Full Code Here


    }

    @AfterClass
    public static void cleanUpClass() {
        System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
        context.reconfigure();
        StatusLogger.getLogger().reset();
    }
View Full Code Here

        verify("entry params(log4j-test1.xml, 5792) TRACE M-ENTRY[ FLOW ] E");
    }

    @SuppressWarnings("unchecked")
    private void verify(final String expected) {
        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
        final Map<String, Appender<?>> list = ctx.getConfiguration().getAppenders();
        final Appender<?> listApp = list.get("List");
        assertNotNull("Missing Appender", listApp);
        assertTrue("Not a ListAppender", listApp instanceof ListAppender);
        final List<String> events = ((ListAppender<String>) listApp).getMessages();
        try
View Full Code Here

        context.setInitParameter(Log4jContextListener.LOG4J_CONFIG, "target/test-classes/log4j2-config.xml");
        final Log4jContextListener listener = new Log4jContextListener();
        final ServletContextEvent event = new ServletContextEvent(context);
        listener.contextInitialized(event);
        LogManager.getLogger("org.apache.test.TestConfigurator");
        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
        Configuration config = ctx.getConfiguration();
        assertNotNull("No configuration", config);
        assertTrue("Incorrect Configuration. Expected " + CONFIG_NAME + " but found " + config.getName(),
            CONFIG_NAME.equals(config.getName()));
        final Map<String, Appender<?>> map = config.getAppenders();
        assertTrue("No Appenders", map != null && map.size() > 0);
        assertTrue("Wrong configuration", map.containsKey("List"));
        listener.contextDestroyed(event);
        config = ctx.getConfiguration();
        assertTrue("Incorrect Configuration. Expected " + NullConfiguration.NULL_NAME + " but found " +
            config.getName(), NullConfiguration.NULL_NAME.equals(config.getName()));
    }
View Full Code Here

        context.setInitParameter(Log4jContextListener.LOG4J_CONFIG, "log4j2-config.xml");
        final Log4jContextListener listener = new Log4jContextListener();
        final ServletContextEvent event = new ServletContextEvent(context);
        listener.contextInitialized(event);
        LogManager.getLogger("org.apache.test.TestConfigurator");
        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
        Configuration config = ctx.getConfiguration();
        assertNotNull("No configuration", config);
        assertTrue("Incorrect Configuration. Expected " + CONFIG_NAME + " but found " + config.getName(),
            CONFIG_NAME.equals(config.getName()));
        final Map<String, Appender<?>> map = config.getAppenders();
        assertTrue("No Appenders", map != null && map.size() > 0);
        assertTrue("Wrong configuration", map.containsKey("List"));
        listener.contextDestroyed(event);
        config = ctx.getConfiguration();
        assertTrue("Incorrect Configuration. Expected " + NullConfiguration.NULL_NAME + " but found " +
            config.getName(), NullConfiguration.NULL_NAME.equals(config.getName()));
    }
View Full Code Here

        context.setInitParameter(Log4jContextListener.LOG4J_CONTEXT_NAME, "-config");
        final Log4jContextListener listener = new Log4jContextListener();
        final ServletContextEvent event = new ServletContextEvent(context);
        listener.contextInitialized(event);
        LogManager.getLogger("org.apache.test.TestConfigurator");
        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
        Configuration config = ctx.getConfiguration();
        assertNotNull("No configuration", config);
        assertTrue("Incorrect Configuration. Expected " + CONFIG_NAME + " but found " + config.getName(),
            CONFIG_NAME.equals(config.getName()));
        final Map<String, Appender<?>> map = config.getAppenders();
        assertTrue("No Appenders", map != null && map.size() > 0);
        assertTrue("Wrong configuration", map.containsKey("List"));
        listener.contextDestroyed(event);
        config = ctx.getConfiguration();
        assertTrue("Incorrect Configuration. Expected " + NullConfiguration.NULL_NAME + " but found " +
            config.getName(), NullConfiguration.NULL_NAME.equals(config.getName()));
    }
View Full Code Here

    public static void tearDownClass() {
    }

    @After
    public void tearDown() {
        final LoggerContext ctx = (LoggerContext) org.apache.logging.log4j.LogManager.getContext();
        ctx.reconfigure();
        a1 = null;
        a2 = null;
    }
View Full Code Here

    @BeforeClass
    public static void setupClass() {
        appender.start();
        ConfigurationFactory.setConfigurationFactory(cf);
        final LoggerContext ctx = (LoggerContext) org.apache.logging.log4j.LogManager.getContext();
        ctx.reconfigure();
    }
View Full Code Here

    static ConfigurationFactory cf = new BasicConfigurationFactory();

    @BeforeClass
    public static void setupClass() {
        ConfigurationFactory.setConfigurationFactory(cf);
        final LoggerContext ctx = (LoggerContext) LogManager.getContext();
        ctx.reconfigure();
    }
View Full Code Here

    @BeforeClass
    public static void setupClass() {
        StatusLogger.getLogger().setLevel(Level.OFF);
        ConfigurationFactory.setConfigurationFactory(cf);
        final LoggerContext ctx = (LoggerContext) LogManager.getContext();
        ctx.reconfigure();
    }
View Full Code Here

TOP

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

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.