Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.dropwizard.logging;
 
 // TODO: 10/12/11 <coda> -- test LoggingBean
 // TODO: 10/12/11 <coda> -- document LoggingBean
 
public class LoggingBean implements LoggingMXBean {
    @Override
    public String getLoggerLevel(String loggerName) {
        return Logger.getLogger(loggerName).getEffectiveLevel().toString();
    }
    @Override
    public List<StringgetLoggerNames() {
        final List<Stringnames = Lists.newArrayList();
        final Enumeration<?> loggers = Logger.getRootLogger()
                                             .getLoggerRepository()
                                             .getCurrentLoggers();
        while (loggers.hasMoreElements()) {
            final Logger logger = (Loggerloggers.nextElement();
            names.add(logger.getName());
        }
        final Enumeration<StringmoreNames = LogManager.getLogManager()
                                                        .getLoggerNames();
        while (moreNames.hasMoreElements()) {
            final String name = moreNames.nextElement();
            names.add(name);
        }
        Collections.sort(names);
        return names;
    }
    @Override
    public void setLoggerLevel(String loggerNameString levelName) {
        final Level newLevel = Level.toLevel(levelName.);
        Logger.getLogger(loggerName).setLevel(newLevel);
    }
    @Override
    public String getParentLoggerName(String loggerName) {
        final Category parent = Logger.getLogger(loggerName).getParent();
        if (parent != null) {
            return parent.getName();
        }
        return null;
    }
New to GrepCode? Check out our FAQ X