title: Logback configuration on tomcat
body: <p>I am using Logback on tomcat (7.0.37). I want to config logback in which it can write web-accessible log files for me but i can even config it to write on console. I cannot format the log message on the console. It always return me with the default format and an exception.</p>
  
  <p><code>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</code></p>
  
  <p>Here are my logback-access.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration debug="true"&gt;
      &lt;statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" /&gt;
  
      &lt;appender name="RootFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
          &lt;file&gt;testing&lt;/file&gt;
          &lt;append&gt;true&lt;/append&gt;
  
          &lt;rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"&gt;
              &lt;fileNamePattern&gt;testing.%i&lt;/fileNamePattern&gt;
              &lt;minIndex&gt;1&lt;/minIndex&gt;
              &lt;maxIndex&gt;12&lt;/maxIndex&gt;
          &lt;/rollingPolicy&gt;
  
          &lt;triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"&gt;
              &lt;maxFileSize&gt;1MB&lt;/maxFileSize&gt;
          &lt;/triggeringPolicy&gt;
  
          &lt;encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"&gt;
              &lt;layout class="ch.qos.logback.classic.html.HTMLLayout"&gt;
                &lt;pattern&gt;%d{yyyy-MM-dd HH:mm:ss} %m%n&lt;/pattern&gt;
              &lt;/layout&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
      &lt;appender name="RootConsoleAppender" class="ch.qos.logback.core.ConsoleAppender"&gt;
          &lt;encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"&gt;
              &lt;pattern&gt;%d{yyyy-MM-dd HH:mm:ss} %-6level- %logger{36}: %msg%n&lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
      &lt;appender-ref ref="RootFileAppender"/&gt;
      &lt;appender-ref ref="RootConsoleAppender"/&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>With this config, i get exception every time when there are http request to my server as below:</p>
  
  <pre><code>18:08:19,951 |-ERROR in ch.qos.logback.core.ConsoleAppender[RootConsoleAppender] - Appender [RootConsoleAppender] failed to append. java.lang.ClassCastException: ch.qos.logback.access.spi.AccessEvent cannot be cast to ch.qos.logback.classic.spi.ILoggingEvent
      at java.lang.ClassCastException: ch.qos.logback.access.spi.AccessEvent cannot be cast to ch.qos.logback.classic.spi.ILoggingEvent
      at  at ch.qos.logback.classic.PatternLayout.doLayout(PatternLayout.java:60)
      at  at ch.qos.logback.core.encoder.LayoutWrappingEncoder.doEncode(LayoutWrappingEncoder.java:134)
      at  at ch.qos.logback.core.OutputStreamAppender.writeOut(OutputStreamAppender.java:188)
      at  at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:212)
      at  at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:103)
      at  at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:88)
      at  at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48)
      at  at ch.qos.logback.access.tomcat.LogbackValve.invoke(LogbackValve.java:182)
      at  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
      at  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at  at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
      at  at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      at  at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
      at  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at  at java.lang.Thread.run(Thread.java:722)
  </code></pre>