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

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


    @BeforeClass
    public static void setupClass() {
        deleteDir();
        System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
        final LoggerContext ctx = (LoggerContext) LogManager.getContext();
        final Configuration config = ctx.getConfiguration();
    }
View Full Code Here


        file.setLastModified(newTime);
        Thread.sleep(6000);
        for (int i = 0; i < 17; ++i) {
            logger.debug("Reconfigure");
        }
        final Configuration cfg = ctx.getConfiguration();
        assertNotNull("No configuration", cfg);
        assertTrue("Reconfiguration failed", cfg != config);
    }
View Full Code Here

    }

    @Test
    public void testConfiguration() throws Exception {
        final LoggerContext ctx = (LoggerContext) LogManager.getContext();
        final Configuration config = ctx.getConfiguration();
        final Map<String, Appender> appenders = config.getAppenders();
        assertTrue(appenders.containsKey("JMSQueue"));
    }
View Full Code Here

        try {
            final InputStream in = new ByteArrayInputStream(
                    configText.getBytes(charsetName));
            final ConfigurationSource source = new ConfigurationSource(in);
            final Configuration updated = ConfigurationFactory.getInstance()
                    .getConfiguration(source);
            loggerContext.start(updated);
            LOGGER.debug("Completed remote request to reconfigure from config text.");
        } catch (final Exception ex) {
            customConfigText = old;
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

            status = Status.STOPPING;
            if (shutdownThread != null) {
                Runtime.getRuntime().removeShutdownHook(shutdownThread);
                shutdownThread = null;
            }
            Configuration prev = config;
            config = new NullConfiguration();
            updateLoggers();
            prev.stop();
            externalContext = null;
            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.
     */
    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

            initializer.initialize();
            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);
            assertTrue("Incorrect value for TestParam: " + value, "ParamValue".equals(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.