Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-985

RollingFileAppender fails to rotate log if underlying jar files also uses logger

    XMLWordPrintable

Details

    Description

      I am using com.mchange.v2.c3p0.ComboPooledDataSource in my application (scala).

      Here is sample code used by my application, which causes this.

      ... 
      val source = new ComboPooledDataSource
      ...
      

      Normally messages from ComboPooledDataSource logs to console. But if console and appender file (see xml below) are same, then RollingFileAppender does not rotate log file. Instead it keeps appending to the same file.

      e.g.
      So for configuration below, we expect new file each minute.
      Expected files after 2 runs in 2 mins are,
      1) /test/logs/application.log and 2) /test/logs/application.2014-05-14_23_34.log

      Instead both run gets logged in /test/logs/application.log.

      I have tested this on intellij and also using wrapper script.

      If stdout is redirected to any log other than /test/logs/application.log, then it works as expected.

      Logback Configuration -

      <configuration>
        <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
          <File>/test/logs/application.log</File>
          <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>/test/logs/application.%d{yyyy-MM-dd_HH_mm}.log</fileNamePattern>
            <maxHistory>20</maxHistory>
          </rollingPolicy>
          <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%X{akkaSource}] [%thread] %-5level %logger{36} - %msg%n</pattern>
          </encoder>
        </appender>
        <root level="info">
          <appender-ref ref="FILE" />
        </root>
      </configuration>
      

      Attachments

        Activity

          People

            logback-dev Logback dev list
            ksathe27 kaustubh sathe
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: