[logback-user] Jetty: How to get multiple web applications log to a common log file

Gaurav Kumar gaurav419 at gmail.com
Tue Oct 30 18:52:17 CET 2012

I am using Jetty webserver and logback for logging.

I have a scenario with multiple Web Applications (so multiple wars into
jetty/webapps dir). Each war has its own copy of logback-classic,
logback-core and slf4j-api. There is a common copy of logback.xml in
jetty/resources (pasted below). My intent is to maintain a logfile named
"testapp.<date>.log" which should be used by all the wars for logging.
Further, I want a rollover of this file on every startup. I am able to
achieve this except that each war is trying to create its own version of
the log file so when each war is loaded it creates its own logfile
archiving the earlier logfile created by the earlier war. This continues
till all wars are loaded thus creating these many log files per startup.
The archived files are are named "testapp.<date>.log.<time in millisec>.

Is there a way to ask all wars to log into the same file?

*logback.xml file content:*

  <timestamp key="dateStr" datePattern="yyyy-MM-dd"
  <timestamp key="timeStr" datePattern="HHmmssSSS"

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
       <pattern>%date{MMM dd}, %date{yyyy hh:mm:ss a} %class
%method\(\):%line %n%level: %message%n </pattern>

  <appender name="FILE"

      <!-- daily rollover -->


      <!-- keep max 30 rolled over files -->

      <!-- Baywatch trigger for daily rollover and every server restart -->
      <timeBasedFileNamingAndTriggeringPolicy class="com.bmc.ola.utils.

        <pattern>%date{MMM dd}, %date{yyyy hh:mm:ss a} %class
%method\(\):%line %n%level: %message%n </pattern>

  <root level="INFO">
    <appender-ref ref="FILE" />

*LogbackLogTriggeringPolicy.java is:*

public class LogbackLogTriggeringPolicy<E> extends
DefaultTimeBasedFileNamingAndTriggeringPolicy<E> {
      public void start() {
          nextCheck = 0L;
          isTriggeringEvent(null, null);
          try {
          } catch (RolloverFailure e) {
              //Do nothing

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20121030/f082ffe5/attachment.html>

More information about the Logback-user mailing list