[logback-user] Specifying the location of the default configuration file via servlet context parameter

Stevo Slavić sslavic at gmail.com
Thu Oct 13 20:28:55 CEST 2011


Hello Logback users,

Logback documentation is great, and in it among other things one can
find example for specifying the location of the default logback
configuration file as a system property (see
http://logback.qos.ch/manual/configuration.html#configFileProperty )

This is nice for command line tools, but not as usable for webapps,
typically each web application is configured with separate logback
configuration file, so if there is more than one application running.

I've found logback-classic has ContextDetachingSCL
(ServletContextListener) for stopping logging context when servlet
context is destroyed.
Maybe similar LogbackConfigurationSCL implementation could be added to
logback-classic, to support specifying the location of the default
configuration file via servlet context parameter (could be named same
as system property, logback.configurationFile) which
LogbackConfigurationSCL would use when context is initialized to
initialize logback configuration.

There is issue though, if both system property and servlet context
parameter were specified, which one should logback use. Typically in
other libraries, tools etc. (like Maven) system property takes
precedence, but in this case, I'm not sure, maybe servlet context
parameter should be given precedence.

What does community think about this feature?

Regards,
Stevo.


More information about the Logback-user mailing list