Search code examples
spring-bootlogback

Logback: TimeBasedRollingPolicy not rolling


I believe I have configured logback to rollover each day, but last night it did not rollover. It has not worked in a while. According to the documentation I have found I am unable to see any faulty configuration. The log file contains expected log lines and levels, but it just does not rollover.

Doc's I have followed

Spring Boot version: 2.0.4.RELEASE

Logback version: 1.2.3

Logback.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
<jmxConfigurator />
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%d | %-5.5p | %-32.32c{0} | %-16.16t | %m%n</pattern>
    </encoder>
</appender>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>log/${project.artifactId}.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>log/${project.artifactId}.log.%d{yyyy-MM-dd}.gz</fileNamePattern>
        <maxHistory>14</maxHistory>
    </rollingPolicy>
    <encoder>
        <pattern>%d | %-5.5p | %-32.32c{0} | %-16.16t | %m%n</pattern>
    </encoder>
</appender>
<root level="INFO">
    <appender-ref ref="console"/>
    <appender-ref ref="file"/>
</root>
<logger name="no.something.cool" level="DEBUG"/>

Snip from log file:

2018-08-07 23:13:42,679 | DEBUG | HandlerService                   | 
ngAgreementRoute | [AOS] No need to update UserToAirlineMap yet
2018-08-07 23:28:42,678 | DEBUG | HandlerService                   | 
ngAgreementRoute | [AOS] No need to update UserToAirlineMap yet
2018-08-07 23:43:42,679 | DEBUG | HandlerService                   | 
ngAgreementRoute | [AOS] No need to update UserToAirlineMap yet
2018-08-07 23:58:42,679 | DEBUG | HandlerService                   | 
ngAgreementRoute | [AOS] No need to update UserToAirlineMap yet
2018-08-08 00:13:42,679 | DEBUG | HandlerService                   | 
ngAgreementRoute | [AOS] No need to update UserToAirlineMap yet
2018-08-08 00:28:42,679 | DEBUG | HandlerService                   | 
ngAgreementRoute | [AOS] No need to update UserToAirlineMap yet

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>no.stuff</groupId>
    <artifactId>javaapp-parent</artifactId>
    <version>1.1.13</version>
</parent>

<groupId>no.stuff.stuff</groupId>
<artifactId>MYAPP</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
<name>Stuff :: Random Stuff</name>

<properties>
    <mainClass>no.stuff.Application</mainClass>
    <cxf-xjc-plugin.version>3.0.5</cxf-xjc-plugin.version>
    <cxf.version>3.1.7</cxf.version>
    <jaxb2-fluent-api.version>3.0</jaxb2-fluent-api.version>
    <fisservices.version>2.0.3</fisservices.version>

    <spring-boot>2.0.4.RELEASE</spring-boot>
    <spring.version>5.0.8.RELEASE</spring.version>

    <jolokia.version>1.3.5</jolokia.version>
    <lombok.version>1.16.6</lombok.version>
    <camel.version>2.16.2</camel.version>
    <jaxb.version>2.2.11</jaxb.version>
    <ibm.mq.version>6.0.2.5</ibm.mq.version>
    <geronimo-j2ee-connector.version>1.0</geronimo-j2ee-connector.version>
    <junit.version>4.10</junit.version>
    <mockito.version>1.9.5</mockito.version>
    <fest.assert.version>1.4</fest.assert.version>
    <jasypt.version>1.9.2</jasypt.version>
    <jasypt-spring-boot-starter.version>2.1.0</jasypt-spring-boot-starter.version>
    <joda-time.version>2.4</joda-time.version>
    <jackson-version>2.9.6</jackson-version>
    <logback.version>1.2.3</logback.version>
</properties>

<build>
    <plugins>
        <plugin> <!-- Compile Java -->
            <artifactId>maven-compiler-plugin</artifactId>
        </plugin>
        <plugin> <!-- Copy and filter all resources -->
            <artifactId>maven-resources-plugin</artifactId>
        </plugin>
        <plugin>
            <artifactId>maven-deploy-plugin</artifactId>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
        <plugin> <!-- Copy all jar dependencies to /jar -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}/jars</outputDirectory>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                        <includeScope>runtime</includeScope>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <jarName>${project.artifactId}</jarName>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>jars</classpathPrefix>
                        <mainClass>${mainClass}</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin> <!-- Generate sources -->
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-xjc-plugin</artifactId>
            <version>${cxf-xjc-plugin.version}</version>
        </plugin>
        <plugin> <!-- Generate sources -->
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
        </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <plugin> <!-- Copy and filter all resources -->
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>prepare-dockerfile</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/docker-filtered</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/docker</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>prepare-compose</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/docker-compose-filtered</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/docker-compose</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>prepare-config</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/config</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/config</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>prepare-logback</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources</directory>
                                    <includes>
                                        <include>logback.xml</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin> <!-- Generate sources -->
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-xjc-plugin</artifactId>
                <configuration>
                    <extensions>
                        <extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:${cxf-xjc-plugin.version}</extension>
                        <extension>org.jvnet.jaxb2_commons:jaxb2-fluent-api:${jaxb2-fluent-api.version}</extension>
                    </extensions>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>xsdtojava</goal>
                        </goals>
                        <configuration>
                            <sourceRoot>${basedir}/target/generated-sources</sourceRoot>
                            <xsdOptions>
                                <xsdOption>
                                    <xsd>src/main/resources/schema/data.xsd</xsd>
                                    <packagename>no.package.stuff</packagename>
                                    <extensionArgs>
                                        <extensionArg>-extension</extensionArg>
                                        <extensionArg>-Xfluent-api</extensionArg>
                                    </extensionArgs>
                                    <bindingFile>${basedir}/src/main/resources/schema/bindings.xml</bindingFile>
                                </xsdOption>
                            </xsdOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin> <!-- Generate sources -->
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                        <configuration>
                            <sourceRoot>${basedir}/target/generated-sources</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>${basedir}/src/main/resources/schema/something.wsdl</wsdl>
                                    <extraargs>
                                        <extraarg>-verbose</extraarg>
                                        <extraarg>-xjc-Xfluent-api</extraarg>
                                        <extraarg>-xjc-b,${basedir}/src/main/resources/schema/bindings.xml</extraarg>
                                        <extraarg>-p</extraarg>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-fluent-api</artifactId>
                        <version>${jaxb2-fluent-api.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </pluginManagement>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
        <resource>
            <directory>src/main/webapp/dist/</directory>
        </resource>
    </resources>
</build>

<dependencies>
    <!-- ============================================================================================ -->
    <!--                        ANYTHING NOT SPRING, CAMEL OR TEST DEPENDENCIES START                 -->
    <!-- ============================================================================================ -->
    <dependency>
        <groupId>com.ibm.eai.fisservices</groupId>
        <artifactId>fisservice-data-definitions</artifactId>
        <version>${fisservices.version}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-yaml</artifactId>
        <version>${jackson-version}</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jsr310</artifactId>
        <version>${jackson-version}</version>
    </dependency>
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>${joda-time.version}</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>${jaxb.version}</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>${jaxb.version}</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${logback.version}</version>
    </dependency>
    <dependency>
        <groupId>org.jolokia</groupId>
        <artifactId>jolokia-jvm</artifactId>
        <classifier>agent</classifier>
        <version>${jolokia.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-core</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <!-- ============================================================================================ -->
    <!--                        ANYTHING NOT SPRING, CAMEL OR TEST DEPENDENCIES END                   -->
    <!-- ============================================================================================ -->

    <!-- ============================================================================================ -->
    <!--                        SPRING BOOT STARTER-DEPENDENCIES START                                -->
    <!-- ============================================================================================ -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>${spring-boot}</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
            <exclusion>
                <artifactId>log4j-over-slf4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
        <version>${spring-boot}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-logging</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>log4j-over-slf4j</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
        <version>${spring-boot}</version>
    </dependency>
    <!--<dependency>-->
        <!--<groupId>org.springframework.boot</groupId>-->
        <!--<artifactId>spring-boot-starter-log4j2</artifactId>-->
        <!--<version>${spring-boot}</version>-->
    <!--</dependency>-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>${spring-boot}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-mongodb</artifactId>
        <version>${spring-boot}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
        <version>${spring-boot}</version>
    </dependency>
    <dependency>
        <groupId>org.jasypt</groupId>
        <artifactId>jasypt</artifactId>
        <version>${jasypt.version}</version>
    </dependency>
    <dependency>
        <groupId>com.github.ulisesbocchio</groupId>
        <artifactId>jasypt-spring-boot-starter</artifactId>
        <version>${jasypt-spring-boot-starter.version}</version>
    </dependency>
    <!-- ============================================================================================ -->
    <!--                        SPRING BOOT STARTER-DEPENDENCIES END                                  -->
    <!-- ============================================================================================ -->

    <!-- ============================================================================================ -->
    <!--                        OTHER SPRING DEPENDENCIES START                                       -->
    <!-- ============================================================================================ -->
    <!-- We generally don't want to depend explicitly on Spring, there we keep this section to itself
     to be explicit about it -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <!-- ============================================================================================ -->
    <!--                        OTHER SPRING DEPENDENCIES END                                       -->
    <!-- ============================================================================================ -->

    <!-- ============================================================================================ -->
    <!--                        CAMEL DEPENDENCIES START                                              -->
    <!-- ============================================================================================ -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring-boot</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-quartz2</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-jasypt</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-test</artifactId>
        <version>${camel.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-test-spring</artifactId>
        <version>${camel.version}</version>
    </dependency>
    <!-- ============================================================================================ -->
    <!--                        CAMEL DEPENDENCIES END                                                -->
    <!-- ============================================================================================ -->

    <!-- ============================================================================================ -->
    <!--                        IBM-MQ DEPENDENCIES START                                              -->
    <!-- ============================================================================================ -->
    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>cl3export</artifactId>
        <version>${ibm.mq.version}</version>
    </dependency>
    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>cl3nonexport</artifactId>
        <version>${ibm.mq.version}</version>
    </dependency>
    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>com.ibm.mq</artifactId>
        <version>${ibm.mq.version}</version>
    </dependency>
    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>com.ibm.mq.jms.nojndi</artifactId>
        <version>${ibm.mq.version}</version>
    </dependency>
    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>com.ibm.mq.soap</artifactId>
        <version>${ibm.mq.version}</version>
    </dependency>
    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>com.ibm.mqjms</artifactId>
        <version>${ibm.mq.version}</version>
    </dependency>
    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>connector</artifactId>
        <version>${ibm.mq.version}</version>
    </dependency>
    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>dhbcore</artifactId>
        <version>${ibm.mq.version}</version>
    </dependency>
    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>jms</artifactId>
        <version>${ibm.mq.version}</version>
    </dependency>
    <dependency>
        <groupId>com.ibm.mq</groupId>
        <artifactId>jta</artifactId>
        <version>${ibm.mq.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-j2ee-connector_1.6_spec</artifactId>
        <version>${geronimo-j2ee-connector.version}</version>
    </dependency>
    <!-- ============================================================================================ -->
    <!--                        IBM-MQ DEPENDENCIES END                                                -->
    <!-- ============================================================================================ -->

    <!-- ============================================================================================ -->
    <!--                        TEST DEPENDENCIES START                                              -->
    <!-- ============================================================================================ -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>${mockito.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.easytesting</groupId>
        <artifactId>fest-assert</artifactId>
        <version>${fest.assert.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <scope>test</scope>
    </dependency>
    <!-- ============================================================================================ -->
    <!--                        TEST DEPENDENCIES END                                              -->
    <!-- ============================================================================================ -->
</dependencies>


Solution

  • Ok, so I think it is working now.

    I ended up with removing every dependency I had to any logging library and building it up from scratch. I ended up with commenting out the following dependecies:

    <!--<dependency>-->
            <!--<groupId>org.springframework.boot</groupId>-->
            <!--<artifactId>spring-boot-starter-logging</artifactId>-->
            <!--<version>${spring-boot}</version>-->
            <!--<exclusions>-->
                <!--<exclusion>-->
                    <!--<artifactId>log4j-over-slf4j</artifactId>-->
                    <!--<groupId>org.slf4j</groupId>-->
                <!--</exclusion>-->
            <!--</exclusions>-->
        <!--</dependency>-->
    

    and

    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${spring-boot}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
                <!--<exclusion>-->
                    <!--<artifactId>log4j-over-slf4j</artifactId>-->
                    <!--<groupId>org.slf4j</groupId>-->
                <!--</exclusion>-->
            </exclusions>
        </dependency>
    

    I still dont understand why removing these dependencies worked. But hey, starting over from scratch is not a bad idea.