[logback-user] runtime configuration
Ceki Gulcu
ceki at qos.ch
Thu Dec 4 16:23:56 CET 2008
LoggerContext.reset (aka shutdownAndReset) does not touch logger levels. This is
a relic from log4j, which behaves in the same way. Would you like the level
values nulled as well?
mateusz jedruch wrote:
> Hi,
> I am preparing something like web interface for my app logging configuration,
> similar to yours JMX configurator.
> As I noticed when you add new logger in the runtime then it is impossible
> to remove it (set its log level null). I have checked the shutdownAndReset()
> and id doesn't work.
>
> I have attached the source code which should explain you what I would like
> achieved. Could you check it?
>
> Thanks,
> -mateusz
>
> package foo;
>
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> import ch.qos.logback.classic.Level;
> import ch.qos.logback.classic.LoggerContext;
> import ch.qos.logback.classic.jmx.Configurator;
>
> public class Main {
>
> private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
>
> public static void main(String[] args) {
> LOGGER.info("Message #1"); //shouldn't be logged, LOGGER's
> level is null so takes root's off level
> LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
> ch.qos.logback.classic.Logger log = lc.getLogger(LOGGER.getName());
> log.setLevel(Level.INFO);
> LOGGER.info("Message #2"); //should be logged, LOGGER's level is info
> Configurator config = new Configurator(lc);
> config.reload(); //shutdownAndReset() is call inside this method
> LOGGER.info("Message #3"); // why it is logged here ? LOGGER's
> level is still INFO, shouldn't be null ?
> }
> }
>
> logback.xml:
>
> <configuration>
> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
> <layout class="ch.qos.logback.classic.PatternLayout">
> <Pattern>%d{HH:mm:ss.SSS} [%thread] %5level %logger{18} -
> %msg%n</Pattern>
> </layout>
> </appender>
>
> <root>
> <level value="off" />
> <appender-ref ref="STDOUT" />
> </root>
> </configuration>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user
>
--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
More information about the Logback-user
mailing list