[
http://jira.qos.ch/browse/LBCLASSIC-202?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12318#action_12318
]
David J. M. Karlsen commented on LBCLASSIC-202:
-----------------------------------------------
You can do pretty much the same with:
{noformat}
<env-entry>
<description>Logback JNDI logging context for this
app</description>
<env-entry-name>logback/context-name</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>PAYS</env-entry-value>
</env-entry>
<env-entry>
<description>Logback URL for configuring logback
context</description>
<env-entry-name>logback/configuration-resource</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>pays/logback.xml</env-entry-value>
</env-entry>
<filter>
<filter-name>LoggerContextFilter</filter-name>
<filter-class>ch.qos.logback.classic.selector.servlet.LoggerContextFilter</filter-class>
</filter>
{noformat}
in your web.xml
> 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
_______________________________________________
logback-dev mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-dev