[logback-user] Logging from Tomcat Webapp

Neeraj Vaidya neeraj.vaidya at yahoo.co.in
Wed Feb 28 05:34:27 CET 2018


I am trying to use logback+slf4j for logging in my Apache Tomcat webapp.
Apache Tomcat version : 9.0.2
Logback Version : 1.2.3
OS : RHEL 6.9 (Santiago)

I have placed the slf4j and logback JAR files in WEB-INF/lib folder of the webapp.

I have the following logback.xml file contents. This file is in WEB-INF/classes :

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
        <property name="logdir" value="/tmp"/>
        <property name="processlogfile" value="mycomp-webapp.log"/>
        <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
        <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
            <!--Pattern>%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} - [%thread] - LEVEL=%-5level - %logger{36} - %msg%n</Pattern-->
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
        <appender name="PROCESS" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <Pattern>%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} - [%thread] - LEVEL=%-5level - %logger{36} - %msg%n</Pattern>

        <logger name="com.mycomp" level="TRACE">
                <appender-ref ref="PROCESS"/>
                 <appender-ref ref="STDOUT"/>

        <root level="TRACE">
                <appender-ref ref="STDOUT"/>
                <appender-ref ref="PROCESS"/>

The log file is created in /tmp (as defined by the configuration above), however, it is empty. And I have lots of trace messages in my webapp. I thought atleast the console appender messages should get logged to catalina.out, but that is also not the case.

At Tomcat startup, I am able to see logback framework is picking up the logback.xml file from the WEB-INF/classes folder and so on, but just no hint of any messages being logged.


More information about the logback-user mailing list