Package ch.qos.logback.classic

Examples of ch.qos.logback.classic.Logger


            return result;
        }

        public boolean setLogLevel(final String name, final SyncopeLoggerLevel level) {
            LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
            Logger logger = lc.getLogger(name);
            if (logger != null) {
                logger.setLevel(level.getLevel());
            }

            return logger != null;
        }
View Full Code Here


        syncopeLogger.setLevel(SyncopeLoggerLevel.fromLevel(level));
        syncopeLogger = loggerDAO.save(syncopeLogger);

        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
        Logger logger = lc.getLogger(name);
        logger.setLevel(level);

        LoggerTO result = new LoggerTO();
        BeanUtils.copyProperties(syncopeLogger, result);

        auditManager.audit(Category.logger, LoggerSubCategory.setLevel, Result.success,
View Full Code Here

        // remove SyncopeLogger from local storage, so that LoggerLoader won't load this next time
        loggerDAO.delete(syncopeLogger);

        // set log level to OFF in order to disable configured logger until next reboot
        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
        Logger logger = lc.getLogger(name);
        logger.setLevel(Level.OFF);

        auditManager.audit(Category.logger, LoggerSubCategory.setLevel, Result.success, String.format(
                "Successfully deleted logger %s (%s)", name, expectedType));

        return loggerToDelete;
View Full Code Here

        /*
         * Foreach SyncopeLogger not found in Logback, create a new Logback logger with given name and level.
         */
        for (SyncopeLogger syncopeLogger : loggerLogs.values()) {
            Logger logger = lc.getLogger(syncopeLogger.getName());
            logger.setLevel(syncopeLogger.getLevel().getLevel());
        }
    }
View Full Code Here

            return result;
        }

        public boolean setLogLevel(final String name, final SyncopeLoggerLevel level) {
            LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
            Logger logger = lc.getLogger(name);
            if (logger != null) {
                logger.setLevel(level.getLevel());
            }

            return logger != null;
        }
View Full Code Here

            context.setPackagingDataEnabled(logConfigManager.isPackagingDataEnabled());
            context.setMaxCallerDataDepth(logConfigManager.getMaxCallerDataDepth());

            // Attach a console appender to handle logging untill we configure
            // one. This would be removed in RootLoggerListener.reset
            final Logger rootLogger = getLoggerContext().getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
            rootLogger.setLevel(Level.INFO);
            rootLogger.addAppender(logConfigManager.getDefaultAppender());

            // Now record the time of reset with a default appender attached to
            // root logger. We also add a milli second extra to account for logs which would have
            // got fired in same duration
            resetStartTime = System.currentTimeMillis() + TimeUnit.MILLISECONDS.toMillis(1);
View Full Code Here

    }

    private void detachAppender(final AppenderInfo ai) {
        if (ai != null) {
            for (final String name : ai.getLoggers()) {
                final Logger logger = loggerContext.getLogger(name);

                logger.detachAppender(ai.appender);
            }
        }
    }
View Full Code Here

    }

    private void attachAppender(final AppenderInfo ai) {
        if (ai != null) {
            for (final String name : ai.getLoggers()) {
                final Logger logger = loggerContext.getLogger(name);

                logger.addAppender(ai.appender);
            }
        }
    }
View Full Code Here

            inError = true;
            addError(errMsg);
            return;
        }

        Logger logger = (Logger) o;

        String appenderName = ec.subst(attributes.getValue(ActionConst.REF_ATTRIBUTE));

        if (OptionHelper.isEmpty(appenderName)) {
            // print a meaningful error message and return
            String errMsg = "Missing appender ref attribute in <appender-ref> tag.";
            inError = true;
            addError(errMsg);

            return;
        }

        @SuppressWarnings("unchecked")
        Map<String, Set<String>> appenderBag =
                (Map<String, Set<String>>) ec.getObjectMap().get(OSGI_APPENDER_REF_BAG);

        if(appenderBag == null){
            appenderBag = new HashMap<String, Set<String>>();
            ec.getObjectMap().put(OSGI_APPENDER_REF_BAG,appenderBag);
        }

        Set<String> loggers = appenderBag.get(appenderName);
        if(loggers == null){
            loggers = new HashSet<String>();
            appenderBag.put(appenderName,loggers);
        }

        loggers.add(logger.getName());
    }
View Full Code Here

    @Test
    public void testAppenderService() throws Exception {
        TestAppender ta = registerAppender("foo.bar", "foo.baz");
        delay();

        Logger bar = (Logger)LoggerFactory.getLogger("foo.bar");
        bar.setLevel(Level.DEBUG);
        Logger baz = (Logger)LoggerFactory.getLogger("foo.baz");
        baz.setLevel(Level.INFO);

        bar.debug("Test message");
        baz.debug("Test message"); // Would not be logged

        // One event should be logged.
        assertEquals(1, ta.events.size());
    }
View Full Code Here

TOP

Related Classes of ch.qos.logback.classic.Logger

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.