[logback-user] Programmatic logback Configuration
Chad La Joie
chad.lajoie at switch.ch
Mon Nov 5 11:06:56 CET 2007
I apologize for being pushy. Are there others on this list? Should I
be using a different list?
Chad La Joie wrote:
> I have an application that ships with two logging configuration files;
> a default logback.xml file (DLF) included in the application JAR and a
> user-editable file (UEF) installed on the filesystem with other
> application configuration files. The DLF is used when the application
> is starting but before the code to read in the UEF is executed.
>
> My current code for reading in the UEF looks like this:
>
> LoggerContext loggerContext = (LoggerContext)
> LoggerFactory.getILoggerFactory();
>
> loggerContext.shutdownAndReset();
>
> JoranConfigurator configurator = new JoranConfigurator();
>
> configurator.setContext(loggerContext);
>
> configurator.doConfigure(configuration.getInputStream());
>
> loggerContext.start();
>
> The behavior I'm seeing though is note quite what I expected. Assume
> the DLF contains a console appender and a logger definition for package
> "foo". The behavior I see when the UEF is loaded is:
>
> - Changes to the logger FOO (e.g. changes in the logging level,
> addition/removal of appenders, etc.) are picked up and become active.
>
> - Declaration of new appenders are picked up and become active (e.g.
> if a new file appender is defined I can see it creating the new log file).
>
> - Declaration of new loggers are *not* picked up. If, for example, a
> logger "bar" is defined and given the same console appender as "foo" no
> output from "bar" is sent to the console.
>
> Is this expected behavior? Is my code wrong (I've tried the same code
> without the start() or shutdownAndReset() method calls)?
>
> Any help would be appreciated.
>
--
SWITCH
Serving Swiss Universities
--------------------------
Chad La Joie, Software Engineer, Security
Werdstrasse 2, P.O. Box, 8021 Zurich, Switzerland
phone +41 44 268 15 75, fax +41 44 268 15 68
chad.lajoie at switch.ch, http://www.switch.ch
More information about the Logback-user
mailing list