ceki, this helped me a lot :) used 3) like so:
/* Calculate run.mode dependent path to logback configuration file.
* Use same naming scheme as for props files. */
val logbackConfFile = {
val propsDir = "props"
val fileNameTail = "default.logback.xml"
val mode = System.getProperty("run.mode")
if (mode != null) propsDir + "/" + mode + "." + fileNameTail
else propsDir + "/" + fileNameTail
}
/* set logback config file appropriately */
System.setProperty("logback.configurationFile", logbackConfFile)
On 20/09/12 22:39, ceki wrote:
Hi Olek,
I can think of three techniques at your disposal. Moreover, they may
be combined if necessary.
1) conditional processing of config files
See http://logback.qos.ch/manual/configuration.html#conditional
This option requires the Janino library. You would have a single
config file parts of which would be activated depending on the value
of the
run.mode property.
2) file inclusion
See http://logback.qos.ch/manual/configuration.html#fileInclusion
The included file would be a system property, say "includedFile". You
would be responsible for setting "includedFile". Here is a sample
logback.xml file:
configuration>
<include file="${includedFile:-/path/to/default/logback.xml}"/>
other configuration directives common to various modes go here...
</configuration>
The above uses default values for variables.
See http://tinyurl.com/bmxcj5w
3) Specifying the location of the default configuration file as a
system property
http://logback.qos.ch/manual/configuration.html#configFileProperty
This third option is probably the simplest. You programmatically set
the "logback.configurationFile" system property to point to the
appropriate config file.
BYW, you can reset any existing configuration by invoking:
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
lc.reset();
Let us know how it goes.
_______________________________________________
Logback-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-user