[logback-user] Multiple log files

c. chris.huisman at gmail.com
Fri Oct 12 17:48:17 CEST 2007


Hi,

I have a couple of applications running on one tomcat instance.  I use the
following xml file for each application substituting contextX for the
application name, however, when I start tomcat only one context is
initialized and all log messages are sent to that context.

Is it possible to have a log file for each application in a tomcat instance?

Thanks,

Chris.

[code]
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>

  <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
    <rollingPolicy class="
ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <FileNamePattern>/var/log/tomcat6/catalina.%i.out</FileNamePattern>
      <MinIndex>1</MinIndex>
      <MaxIndex>7</MaxIndex>
    </rollingPolicy>
    <triggeringPolicy class="
ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <MaxFileSize>5MB</MaxFileSize>
    </triggeringPolicy>
    <layout class="ch.qos.logback.classic.PatternLayout">
      <pattern>%d %-5level [%thread] %class | %msg%n</pattern>
    </layout>
  </appender>

  <appender name="contextX" class="
ch.qos.logback.core.rolling.RollingFileAppender">
    <File>/var/log/tomcat6/contextX.log</File>
    <rollingPolicy
      class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

<FileNamePattern>/var/log/tomcat6/contextX.%d.log</FileNamePattern>
    </rollingPolicy>
    <layout class="ch.qos.logback.classic.PatternLayout">
      <pattern>%date{ISO8601} %-5level [%thread] %class | %msg%n</pattern>
    </layout>
    <Encoding>UTF-8</Encoding>
    <BufferedIO>false</BufferedIO>
    <ImmediateFlush>true</ImmediateFlush>
  </appender>

  <logger name="org.springframework" additivity="false">
    <level value="WARN"/>
    <appender-ref ref="contextX" />
  </logger>
  <logger name="com.contextX" additivity="false">
    <level value="WARN"/>
    <appender-ref ref="contextX" />
  </logger>
  <logger name="org.hibernate" additivity="false">
    <level value="WARN"/>
    <appender-ref ref="contextX" />
  </logger>
  <logger name="org.apache.velocity" additivity="false">
    <level value="WARN"/>
    <appender-ref ref="contextX" />
  </logger>
  <logger name="org.acegisecurity" additivity="false">
    <level value="INFO"/>
    <appender-ref ref="contextX" />
  </logger>
  <logger name="org.directwebremoting" additivity="false">
    <level value="WARN"/>
    <appender-ref ref="contextX" />
  </logger>

  <logger name="org.apache" additivity="false">
    <level value="WARN"/>
    <appender-ref ref="stdout" />
  </logger>

  <root>
    <level value="WARN"/>
    <appender-ref ref="stdout"/>
  </root>
</configuration>
[code]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://qos.ch/pipermail/logback-user/attachments/20071012/676c1d54/attachment.htm 


More information about the Logback-user mailing list