Tomcat – logging all HTTP traffic with Logback

1. Install logback in a tomcat\lib folder

2. Create a logback-access.xml in a tomcat\conf foler

  <appender name="cgFileRoller" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

  <appender-ref ref="cgFileRoller" />

3. Modify server.xml in a tomcat/conf folder

      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>
        <Valve className="ch.qos.logback.access.tomcat.LogbackValve"/>


4. Modify web.xml to register filer


This entry was posted in Uncategorized. Bookmark the permalink.

4 Responses to Tomcat – logging all HTTP traffic with Logback

  1. Tom Pijl says:

    I assume this is tested on Tomcat 7, right?

  2. Charmi says:

    Hello By doing this should I be able to print e.printstacktrace() output to console?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s