Surya Chaitanya
Surya Chaitanya

Reputation: 602

SL4JF in Tomcat not showing up in log files

I have installed Tomcat, and using SLF4J as our logging framework. I copied slf4j-api-1.6.4.jar and slf4j-jdk14-1.6.4.jar into the Tomcat library i.e $TOMCAT_HOME/lib.

I assumed that if I use SLF4J, it shall delegate to java.util.Logger, which will delegate to underlying Tomcat logging framework. But when I deploy and check my application, I don't see anything getting logged. All my exception/log information is getting lost.

Is my understanding right, or did I miss anything to keep in class-path?

Upvotes: 8

Views: 5899

Answers (3)

alexkasko
alexkasko

Reputation: 4915

You can configure Tomcat to use log4j as described in its docs, put log4j.properties to $CATALINA_HOME/lib directory and use slf4j-api with slf4j-log4j12 bridge. So you've got clean slf4j API and log4j goodness like DailyRollingFileAppender etc.

Upvotes: 1

Surya Chaitanya
Surya Chaitanya

Reputation: 602

Instead of copying the slf4j-api-1.6.4.jar and slf4j-jdk14-1.6.4.jar under $TOMCAT/lib, i shipped these jars with the war application. in this case my exceptions are getting logged.

Upvotes: 2

Daniel Baktiar
Daniel Baktiar

Reputation: 1712

Probably what you need is to add the system property to the your CATALINA_OPTS.

For Windows systems, add to your %CATALINA_HOME\bin\catalina.bat file:

set CATALINA_OPTS=-Djava.util.logging.config.file=\PATH\TO\YOUR\logging.properties

or on Linux/UNIX systems, add to your $CATALINA_HOME/bin/catalina.sh file:

CATALINA_OPTS=-Djava.util.logging.config.file=/PATH/TO/YOUR/logging.properties

Don't forget that in Linux/UNIX systems, you need to quote if you have more than one parameters in the CATALINA_OPTS, e.g.

CATALINA_OPTS="-Xmx256m -Djava.util.logging.config.file=/PATH/TO/YOUR/logging.properties"

This line is to ensure that your logging.properties file is being loaded when Tomcat is started.

Upvotes: 1

Related Questions