Package org.apache.logging.log4j.core.config

Examples of org.apache.logging.log4j.core.config.Configuration


        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


        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

        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

            status = Status.STOPPING;
            if (shutdownThread != null) {
                Runtime.getRuntime().removeShutdownHook(shutdownThread);
                shutdownThread = null;
            }
            Configuration prev = config;
            config = new NullConfiguration();
            updateLoggers();
            prev.stop();
            externalContext = null;
            LogManager.getFactory().removeContext(this);
            status = Status.STOPPED;
        } finally {
            configLock.unlock();
View Full Code Here

     */
    private synchronized Configuration setConfiguration(final Configuration config) {
        if (config == null) {
            throw new NullPointerException("No Configuration was provided");
        }
        final Configuration prev = this.config;
        config.addListener(this);
        final Map<String, String> map = new HashMap<String, String>();
        map.put("hostName", NetUtils.getLocalHostname());
        map.put("contextName", name);
        config.addComponent(Configuration.CONTEXT_PROPERTIES, map);
        config.start();
        this.config = config;
        updateLoggers();
        if (prev != null) {
            prev.removeListener(this);
            prev.stop();
        }

        // notify listeners
        PropertyChangeEvent evt = new PropertyChangeEvent(this, PROPERTY_CONFIG, prev, config);
        for (PropertyChangeListener listener : propertyChangeListeners) {
View Full Code Here

    /**
     * Reconfigure the context.
     */
    public synchronized void reconfigure() {
        LOGGER.debug("Reconfiguration started for context " + name);
        final Configuration instance = ConfigurationFactory.getInstance().getConfiguration(name, configLocation);
        setConfiguration(instance);
        /*
         * instance.start(); Configuration old = setConfiguration(instance);
         * updateLoggers(); if (old != null) { old.stop(); }
         */
 
View Full Code Here

     * @param reconfigurable The Configuration that can be reconfigured.
     */
    @Override
    public synchronized void onChange(final Reconfigurable reconfigurable) {
        LOGGER.debug("Reconfiguration started for context " + name);
        final Configuration config = reconfigurable.reconfigure();
        if (config != null) {
            setConfiguration(config);
            LOGGER.debug("Reconfiguration completed");
        } else {
            LOGGER.debug("Reconfiguration failed");
View Full Code Here

        try {
            InputStream in = new ByteArrayInputStream(
                    configText.getBytes(charsetName));
            ConfigurationSource source = new ConfigurationSource(in);
            Configuration updated = ConfigurationFactory.getInstance()
                    .getConfiguration(source);
            loggerContext.start(updated);
            LOGGER.debug("Completed remote request to reconfigure from config text.");
        } catch (Exception ex) {
            customConfigText = old;
View Full Code Here

            initializer.start();
            initializer.setLoggerContext();
            LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
            assertNotNull("No LoggerContext", ctx);
            assertNotNull("No ServletContext", ctx.getExternalContext());
            Configuration configuration = ctx.getConfiguration();
            assertNotNull("No configuration", configuration);
            Appender appender = configuration.getAppender("Servlet");
            assertNotNull("No ServletAppender", appender);
            Logger logger = LogManager.getLogger("Test");
            logger.info("This is a test");

        } catch (final IllegalStateException e) {
View Full Code Here

            initializer.start();
            initializer.setLoggerContext();
            LoggerContext ctx = ContextAnchor.THREAD_CONTEXT.get();
            assertNotNull("No LoggerContext", ctx);
            assertNotNull("No ServletContext", ctx.getExternalContext());
            Configuration config = ctx.getConfiguration();
            assertNotNull("No Configuration", config);
            StrSubstitutor substitutor = config.getStrSubstitutor();
            assertNotNull("No Interpolator", substitutor);
            String value = substitutor.replace("${web:initParam.TestParam}");
            assertNotNull("No value for TestParam", value);
            assertEquals("Incorrect value for TestParam: " + value, "ParamValue", value);
            value = substitutor.replace("${web:attr.TestAttr}");
View Full Code Here

TOP

Related Classes of org.apache.logging.log4j.core.config.Configuration

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.