Hi,<br><br>Is it possible to use the substitution property mechanism from code when initializing logback?<br><br>LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();<br>try {<br> JoranConfigurator configurator = new JoranConfigurator();<br>
configurator.setContext(lc);<br> lc.shutdownAndReset();<br><br> // Can't set the property here because the execution context is null<br><br> configurator.doConfigure(contextProperties.getProperty("logging.properties"));<br>
<br> configurator.getExecutionContext().addSubstitutionProperty("<a href="http://service.name">service.name</a>", "serviceOne"); // I think this is to late to set the property and it isn't used anymore<br>
}<br>catch (JoranException je) {<br> StatusPrinter.print(lc);<br>}<br><br>with configuration file:<br><?xml version="1.0" encoding="UTF-8"?><br><br><configuration><br> <appender name="console" class="ch.qos.logback.core.ConsoleAppender"><br>
<layout class="ch.qos.logback.classic.PatternLayout"><br> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M [%line] - %msg%n</pattern><br> </layout><br> </appender><br>
<appender name="A2" class="ch.qos.logback.core.rolling.RollingFileAppender"><br> <file>log/${<a href="http://service.name">service.name</a>}.log</file><br> <Append>true</Append><br>
<layout class="ch.qos.logback.classic.PatternLayout"><br> <pattern>>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M [%line] - %msg%n</pattern><br> </layout><br> <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"><br>
<MaxFileSize>10MB</MaxFileSize><br> </triggeringPolicy><br> <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"><br> <FileNamePattern>log/${<a href="http://service.name">service.name</a>}.%i.log.zip</FileNamePattern><br>
<MinIndex>1</MinIndex><br> <MaxIndex>10</MaxIndex><br> </rollingPolicy><br> </appender><br> <root><br> <level value="INFO"/><br> <appender-ref ref="console"/><br>
</root><br></configuration><br><br>making every service that reuses this configuration but log to it's own logfile.<br><br>Thanking you in advance,<br><br>Tom<br>