[logback-user] how to add substitutionProperties in code

Ceki Gulcu ceki at qos.ch
Tue Mar 11 21:38:56 CET 2008

Hello Tom,

You can put properties into any Context, in particular LoggerContext. So for 

   lc.setProperty("service.name", "serviceOne");

will work in logback 0.9.9-SNAPSHOT. I am not so sure about 0.9.8.

I hope this helps,

Tom Eyckmans wrote:
> Hi,
> Is it possible to use the substitution property mechanism from code when 
> initializing logback?
> LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
> try {
>         JoranConfigurator configurator = new JoranConfigurator();
>         configurator.setContext(lc);
>         lc.shutdownAndReset();
>        // Can't set the property here because the execution context is null
> configurator.doConfigure(contextProperties.getProperty("logging.properties"));
> configurator.getExecutionContext().addSubstitutionProperty("service.name 
> <http://service.name>", "serviceOne"); // I think this is to late to set 


> Tom

Ceki Gülcü
QOS.ch is looking to hire talented developers in Switzerland.  If
interested, please contact c e k i @ q o s . c h

More information about the Logback-user mailing list