[logback-dev] [JIRA] Commented: (LBCLASSIC-202) ServletContextListener to relocate logback config, implementation provided
Eugen Paraschiv (JIRA)
noreply-jira at qos.ch
Sun Nov 27 15:43:14 CET 2011
[ http://jira.qos.ch/browse/LBCLASSIC-202?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12317#action_12317 ]
Eugen Paraschiv commented on LBCLASSIC-202:
-------------------------------------------
Any new development on this?
> ServletContextListener to relocate logback config, implementation provided
> --------------------------------------------------------------------------
>
> Key: LBCLASSIC-202
> URL: http://jira.qos.ch/browse/LBCLASSIC-202
> Project: logback-classic
> Issue Type: New Feature
> Affects Versions: 0.9.20
> Reporter: Attila Király
> Assignee: Logback dev list
> Attachments: LogbackConfigListener.java, LogbackConfigListener2.java
>
>
> In spring there is a Log4jConfigListener which can be used to reconfigure the default location of the log4j config. I always liked to use it because so I could relocate my log4j.xml from the classes directory next to the web.xml so the config files were at one place. Because I did not find something like that I wrote one for logback. I think it could be included into logback-classic.
> ch.qos.logback.classic.servlet.LogbackConfigListener configuration is very easy:
> 1. Add the listener to the web.xml (it should be the first listener so logback gets configured before the other listeners start up):
> <listener>
> <listener-class>ch.qos.logback.classic.servlet.LogbackConfigListener</listener-class>
> </listener>
> 2. Add a context-param to web.xml to specify the location of the logback config:
> <context-param>
> <param-name>logbackConfigLocation</param-name>
> <param-value>/WEB-INF/log.xml</param-value>
> </context-param>
> And thats it. The location is resolved in the following way (similar to spring aproach):
> - if the location starts with "/" it is resolved as servlet context resource
> - otherwise an URL is constructed from it. So you can use locations like this also: file:/foo/bar/logback.xml or file:d:/foo/bar/logback.xml
> - if the the first method fails a java.io.FileInputStream is created from the location to be used as input for logback configuration.
> - If none of the above worked an error is logged to servlet log but no exception is thrown.
> The location can contain system properties, those gets resolved. So a location can be configured for example to: file:${user.home}/configuration/log.xml
> The original spring listener only worked with expanded wars this logback variant does not have this requirement.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the logback-dev
mailing list