To configure tomcat in order to use LogbackValve, the following lines must be added to the tomcat's server.xml, nested in an Engine
element:
<Valve className="ch.qos.logback.access.tomcat.LogbackValve"/>
By default, LogbackValve looks for a logback configuration file called logback-access.xml, in the same folder where the tomcat configuration is located, that is $TOMCAT_HOME/conf/logback-access.xml. The format of logback-access configuration file is only slightly different than for logback-classic. Most of it remains the same: Appenders and Layouts are declared the same way. However, since logback-access has no notion of declared loggers, logger elements are not allowed.
Here is a sample logback.xml file that can be used right away:
<configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <layout class="ch.qos.logback.access.PatternLayout"> <param name="Pattern" value="%date %server %remoteIP %clientHost %user %requestURL " /> </layout> </appender> <appender-ref ref="STDOUT" /> </configuration>A special, module-specific implementation of PatternLayout was implemented to allow http-specific patterns to be used. The {@link ch.qos.logback.access.PatternLayout} provides a way to format thelogging output that is just as easy and flexible as the usual PatternLayout. For more information about the general use of a PatternLayout, please refer to logback classic's {@link ch.qos.logback.classic.PatternLayout}. For information about logback access' specific PatternLayout, please refer to it's javadoc.
@author Ceki Gülcü @author Sébastien Pennec
|
|
|
|