Logging from Tomcat Webapp

Hi, 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"> <encoder> <!--Pattern>%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} - [%thread] - LEVEL=%-5level - %logger{36} - %msg%n</Pattern--> <Pattern>%msg%n</Pattern> </encoder> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>TRACE</level> </filter> </appender> <appender name="PROCESS" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${logdir}/${processlogfile}</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${logdir}/${processlogfile}.%d{yyyy-MM-dd}.%i </fileNamePattern> <maxHistory>10</maxHistory> <maxFileSize>10MB</maxFileSize> </rollingPolicy> <encoder> <Pattern>%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX} - [%thread] - LEVEL=%-5level - %logger{36} - %msg%n</Pattern> </encoder> </appender> <logger name="com.mycomp" level="TRACE"> <appender-ref ref="PROCESS"/> <appender-ref ref="STDOUT"/> </logger> <root level="TRACE"> <appender-ref ref="STDOUT"/> <appender-ref ref="PROCESS"/> </root> </configuration> 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. Regards, Neeraj
participants (1)
-
Neeraj Vaidya