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

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


    public class BasicConfiguration extends BaseConfiguration {

        private static final String DEFAULT_LEVEL = "org.apache.logging.log4j.level";

        public BasicConfiguration() {
            LoggerConfig root = getRootLogger();
            setName("BasicConfiguration");
            String levelName = System.getProperty(DEFAULT_LEVEL);
            Level level = (levelName != null && Level.valueOf(levelName) != null) ? Level.valueOf(levelName) : Level.DEBUG;
            root.setLevel(level);
        }
View Full Code Here


    /**
     * Returns the parent of this Logger. If it doesn't already exist return a temporary Logger.
     * @return The parent Logger.
     */
    public Logger getParent() {
        LoggerConfig lc = config.loggerConfig.getParent();
        if (lc == null) {
            return null;
        }
        if (context.hasLogger(lc.getName())) {
            return context.getLogger(getName());
        }
        return new Logger(context, getName());
    }
View Full Code Here

    /**
     * Return the parent of this Logger. If it doesn't already exist return a temporary Logger.
     * @return The parent Logger.
     */
    public Logger getParent() {
        LoggerConfig lc = config.loggerConfig.getParent();
        if (lc == null) {
            return null;
        }
        if (context.hasLogger(lc.getName())) {
            return context.getLogger(name);
        }
        return new Logger(context, name);
    }
View Full Code Here

                assertThat(forcedConsoleAppender, notNullValue());
                assertThat(forcedConsoleAppender.getName(), equalTo("Forced-Console"));
                assertThat(forcedConsoleAppender.isStarted(), is(true));

                LoggerConfig rootLogger = ((AbstractConfiguration) context.getConfiguration()).getRootLogger();
                verify(rootLogger).addAppender(forcedConsoleAppender, Level.INFO, null);
            }
        });
    }
View Full Code Here

        withForceConsoleLog(new Runnable()
        {
            @Override
            public void run()
            {
                LoggerConfig rootLogger = ((AbstractConfiguration) context.getConfiguration()).getRootLogger();
                Collection<Appender> appenders = new ArrayList<>();
                appenders.add(ConsoleAppender.createAppender(mock(Layout.class), null, null, "Console", null, null));
                when(rootLogger.getAppenders().values()).thenReturn(appenders);

                contextConfigurer.configure(context);
                verify(context.getConfiguration(), never()).addAppender(any(ConsoleAppender.class));
                verify(rootLogger, never()).addAppender(any(ConsoleAppender.class), same(Level.INFO), any(Filter.class));
            }
View Full Code Here

    private static void registerLoggerConfigs(final LoggerContext ctx, final MBeanServer mbs, final Executor executor)
            throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {

        final Map<String, LoggerConfig> map = ctx.getConfiguration().getLoggers();
        for (final String name : map.keySet()) {
            final LoggerConfig cfg = map.get(name);
            final LoggerConfigAdmin mbean = new LoggerConfigAdmin(ctx.getName(), cfg);
            register(mbs, mbean, mbean.getObjectName());

            if (cfg instanceof AsyncLoggerConfig) {
                AsyncLoggerConfig async = (AsyncLoggerConfig) cfg;
View Full Code Here

    protected void doSetUpBeforeMuleContextCreation() throws Exception
    {
        super.doSetUpBeforeMuleContextCreation();

        LoggerContext context = (LoggerContext) LogManager.getContext(false);
        LoggerConfig rootLogger = ((AbstractConfiguration) context.getConfiguration()).getRootLogger();
        Appender appender = new TestAppender("testAppender", null, null);
        context.getConfiguration().addAppender(appender);
        rootLogger.addAppender(appender, Level.WARN, null);

        context.updateLoggers();
    }
View Full Code Here

    /**
     * Returns the parent of this Logger. If it doesn't already exist return a temporary Logger.
     * @return The parent Logger.
     */
    public Logger getParent() {
        final LoggerConfig lc = config.loggerConfig.getParent();
        if (lc == null) {
            return null;
        }
        if (context.hasLogger(lc.getName())) {
            return context.getLogger(getName(), getMessageFactory());
        }
        return new Logger(context, getName(), this.getMessageFactory());
    }
View Full Code Here

    /**
     * Return the parent of this Logger. If it doesn't already exist return a temporary Logger.
     * @return The parent Logger.
     */
    public Logger getParent() {
        LoggerConfig lc = config.loggerConfig.getParent();
        if (lc == null) {
            return null;
        }
        if (context.hasLogger(lc.getName())) {
            return context.getLogger(name);
        }
        return new Logger(context, name);
    }
View Full Code Here

        private static final String DEFAULT_LEVEL = "org.apache.logging.log4j.level";

        public BasicConfiguration() {

            LoggerConfig root = getRootLogger();
            String l = System.getProperty(DEFAULT_LEVEL);
            Level level = (l != null && Level.valueOf(l) != null) ? Level.valueOf(l) : Level.ERROR;
            root.setLevel(level);
        }
View Full Code Here

TOP

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

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.