Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 630
Surya Chaitanya Avatar asked Mar 03 '12 06:03

Surya Chaitanya


People also ask

How do I view Tomcat logs?

The main Apache Tomcat configuration file is at /opt/bitnami/tomcat/conf/server. xml. Once Apache Tomcat starts, it will create several log files in the /opt/bitnami/tomcat/logs directory.

Where are Tomcat application logs?

This file is located in the logs directory below the Tomcat root directory. This log is the system's output log, which also consists of standard error messages. These files are saved daily (MM-DD-YYYY) with the date appended to the name of the data. Moreover, this log file persists during the functioning of the server.

How do I find Tomcat Catalina logs?

By default, the catalina. out file is located in the logs directory under Tomcat's root directory. For example, /opt/netiq/idm/apps/tomcat/logs/catalina.

What is the default log file name in Tomcat?

By default, the Tomcat HTTP Access Logs are stored in the dotserver/tomcat-X.x/logs/ folder within the dotCMS distribution, and the files are named dotcms_access. YYYY-MM-DD. log, where the YYYY-MM-DD in the file name is replaced by the date of the log file.


2 Answers

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.

like image 180
Surya Chaitanya Avatar answered Sep 19 '22 05:09

Surya Chaitanya


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.

like image 39
Daniel Baktiar Avatar answered Sep 20 '22 05:09

Daniel Baktiar