[slf4j-user] slf4j logger -> Servlet container log : How to?
Thorbjoern Ravn Andersen
ravn at runjva.com
Tue May 11 18:42:02 CEST 2010
Den 11/05/10 18.32, Jacob Kjome skrev:
> In web.xml...
>
> <listener>
> <listener-class>
> org.apache.log4j.servlet.ServletContextLogAppenderListener
> </listener-class>
> </listener>
>
> in log4j.xml...
>
> <appender name="ServletContext"
> class="org.apache.log4j.servlet.ServletContextLogAppender">
> <param name="servletContextPath" value="/mycontext"/>
> <param name="Threshold" value="debug"/>
> <layout class="org.apache.log4j.PatternLayout">
> <param name="ConversionPattern" value="[%-5p][%-8.8t]: %39.39c %x- %m"/>
> </layout>
> </appender>
>
> Notice the conversion pattern ends with "%m" instead of "%m%n". This
> is because when the message goes through the servlet context logging
> mechanism, the latter adds the newline, so adding it to the conversion
> pattern above would result in 2 newlines, which is why we leave it out.
Ok. So if I understand this correctly, your approach uses a servlet
listener to register all contexts keyed by the last part of their
context path, and you tell the appender in question which ServletContext
to retrieve and then forward to that logger.
Will this also work with multiple web apps using slf4j, or will they go
to the same appender?
--
Thorbjørn Ravn Andersen "...plus... Tubular Bells!"
More information about the slf4j-user
mailing list