Question

I have a WebApp that I develop using NetBeans 7.4. I deploy it on a Linux server running Tomcat 7.0.47.

I am trying to have a decent logging mechanism with slf4j and logback.

My project uses the following jars:

  • slf4j-api-1.7.6.jar
  • logback-classic-1.1.1.jar
  • logback-core-1.1.1.jar

My app is a SOAP server. At the head of the service class I put:

private static final String nameOfLogger = MatrixSoapService.class.getName();

private static final Logger soapLogger = LoggerFactory.getLogger(nameOfLogger);

then when I need to log something:

soapLogger.info("Init");

etc...

Ok. That's for the context.

My question is: how do I configure this to have rolling logs in my $CATALINE_HOME/conf folder for this application?

I thought I only needed to create a simple logback.xml file in the src folder of my webapp like this, but to no avail. I have no log generated.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
      <Pattern>mySOAP - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
    </layout>
  </appender>
   
  <logger name="com.xxx" level="TRACE"/>
 
  <root level="debug">
    <appender-ref ref="STDOUT" />
  </root>
</configuration>
Was it helpful?

Solution

The main issue was that the location of that file was wrong. I put it now in

/webapps/your-app/WEB-INF/classes/

and at least the content of that logback.xml is used

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top