javaspring-mvclogginglogbackspring-logback

logback - show only errors in catalina.out


I have this file logback-spring.xml:

<configuration>

    <property name="DEV_HOME" value="./logs" />

    <appender name="FILE-AUDIT"  class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${DEV_HOME}/dana.log</file>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%black(%date{"yyyy-MM-dd HH:mm:ss.SSS", "Europe/Brussels"}) %highlight(%-5level) [%green(%X{sessionId})] %yellow(%logger{36}@%method\(%line\)) - %msg%n%throwable</pattern>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- rollover daily -->
            <fileNamePattern>${DEV_HOME}/archive/dana.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy
                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>1MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>

    </appender>

    <appender name="FILE-AUDITSPRING"  class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${DEV_HOME}/springframework.log</file>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%date{"yyyy-MM-dd'T'HH:mm:ss,SSSXXX", Europe/Brussels} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>

        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- rollover daily -->
            <fileNamePattern>${DEV_HOME}/archive/springframework.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy
                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>1MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>

    </appender>

<appender name="FILE-CATALINA"  class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${DEV_HOME}/catalina.out</file>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <pattern>%black(%date{"yyyy-MM-dd HH:mm:ss.SSS", "Europe/Brussels"}) %highlight(%-5level) [%green(%X{sessionId})] %yellow(%logger{36}@%method\(%line\)) - %msg%n%throwable</pattern>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <!-- rollover daily -->
        <fileNamePattern>${DEV_HOME}/archive/catalina.out.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
        <timeBasedFileNamingAndTriggeringPolicy
                class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>1MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
    </rollingPolicy>

</appender>

<root level="ERROR">
    <appender-ref ref="FILE-CATALINA" />
</root>

    <appender name="FILE-AUDIT-WF"  class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${DEV_HOME}/activiti.log</file>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%date{"yyyy-MM-dd'T'HH:mm:ss,SSSXXX", Europe/Brussels} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>

        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- rollover daily -->
            <fileNamePattern>${DEV_HOME}/archive/activiti.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy
                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <maxFileSize>1MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
        </rollingPolicy>

    </appender>


    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender" >
        <encoder>
            <pattern>%date{"yyyy-MM-dd'T'HH:mm:ss,SSSXXX", Europe/Brussels} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="ERROR">
        <appender-ref ref="CONSOLE" />
    </root>

    <root level="ERROR">
        <appender-ref ref="STDOUT" />
    </root>

    <!--springProfile name="dev"-->
        <logger name="com.keuroa.em" level="error" additivity="true">
            <appender-ref ref="FILE-AUDIT" />
        </logger>
        <logger name="org.springframework" level="error" additivity="true">
            <appender-ref ref="FILE-AUDITSPRING" />
        </logger>

        <logger name="org.activiti" level="error" additivity="true">
            <appender-ref ref="FILE-AUDIT-WF" />
        </logger>
        <logger name="org.activiti5" level="error" additivity="true">
            <appender-ref ref="FILE-AUDIT-WF" />
        </logger>
    <!--/springProfile-->

    <springProfile name="prod">
        <logger name="com.keuroa.em" level="WARN" additivity="false">
            <appender-ref ref="FILE-AUDIT" />
        </logger>
        <logger name="org.springframework" level="WARN" additivity="false">
            <appender-ref ref="FILE-AUDITSPRING" />
        </logger>

        <logger name="org.activiti" level="WARN" additivity="false">
            <appender-ref ref="FILE-AUDIT-WF" />
        </logger>
        <logger name="org.activiti5" level="WARN" additivity="false">
            <appender-ref ref="FILE-AUDIT-WF" />
        </logger>
    </springProfile>



    <logger name="org.springframework.security" level="ERROR" />


</configuration>

but in {server}/logs/tomcat/catalina.out, I see

7:01:33.324 [activiti-acquire-timer-jobs] DEBUG org.activiti.engine.impl.persistence.entity.TimerJobEntityImpl.selectTimerJobsToExecute - ==>  Preparing: select * from ( select a.*, ROWNUM rnum from ( select RES.* from ACT_RU_TIMER_JOB RES where DUEDATE_ <= ? and LOCK_OWNER_ is null ) a where ROWNUM < ?) where rnum >= ? 
17:01:33.325 [activiti-acquire-timer-jobs] DEBUG org.activiti.engine.impl.persistence.entity.TimerJobEntityImpl.selectTimerJobsToExecute - ==> Parameters: 2024-11-07 17:01:33.324(Timestamp), 2(Integer), 1(Integer)
17:01:33.326 [activiti-acquire-timer-jobs] DEBUG org.activiti.engine.impl.persistence.entity.TimerJobEntityImpl.selectTimerJobsToExecute - <==      Total: 0
17:01:33.326 [activiti-acquire-timer-jobs] DEBUG org.activiti.engine.impl.db.DbSqlSession - Flushing dbSqlSession
17:01:33.326 [activiti-acquire-timer-jobs] DEBUG org.activiti.engine.impl.db.DbSqlSession - flush summary: 0 insert, 0 update, 0 delete.
17:01:33.326 [activiti-acquire-timer-jobs] DEBUG org.activiti.engine.impl.db.DbSqlSession - now executing flush...
17:01:33.326 [activiti-acquire-timer-jobs] DEBUG org.apache.ibatis.transaction.managed.ManagedTransaction - Closing JDBC Connection [Transaction-aware proxy for target Connection [ProxyConnection[PooledConnection[oracle.jdbc.driver.T4CConnection@65a0287e]]]]
17:01:33.326 [activiti-acquire-timer-jobs] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Initiating transaction commit
17:01:33.326 [activiti-acquire-timer-jobs] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Committing JPA transaction on EntityManager [org.eclipse.persistence.internal.jpa.EntityManagerImpl@7591a8b2]
17:01:33.326 [activiti-acquire-timer-jobs] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Closing JPA EntityManager [org.eclipse.persistence.internal.jpa.EntityManagerImpl@7591a8b2] after transaction
17:01:33.326 [activiti-acquire-timer-jobs] DEBUG org.activiti.engine.impl.interceptor.LogInterceptor - --- AcquireTimerJobsCmd finished --------------------------------------------------------
17:01:33.326 [activiti-acquire-timer-jobs] DEBUG org.activiti.engine.impl.interceptor.LogInterceptor - 

Solution

  • There are multiple root definitions and a reference to a "CONSOLE" appender that is not defined.

    In the logback-spring.xml example you share there are multiple root definitions (FILE-CATALINA, CONSOLE, STDOUT). Also, apparently there is a reference to a "CONSOLE" appender that is not defined.

    Try:

    As a reference, you could base it on something like the following:

    <configuration>
        <property name="DEV_HOME" value="./logs" />
    
        <!-- ... others appenders ... -->
    
        <!-- only one root config -->
        <root level="ERROR">
            <appender-ref ref="FILE-CATALINA" />
            <appender-ref ref="STDOUT" />
        </root>
    
        <!--  Activiti Config-->
        <logger name="org.activiti" level="ERROR" additivity="false">
            <appender-ref ref="FILE-AUDIT-WF" />
            <appender-ref ref="FILE-CATALINA" />
        </logger>
        
        <logger name="org.activiti.engine" level="ERROR" additivity="false">
            <appender-ref ref="FILE-AUDIT-WF" />
            <appender-ref ref="FILE-CATALINA" />
        </logger>
    
        <!-- ... other configs ... -->
    </configuration>