Configure JDK Logging in Tomcat

When developing from Eclipse, it is useful to increase the log level to say FINE. In this article, we will see how to do this. I tested this out using TomEE 1.5, but, this should work for Tomcat 7 also.

image

In the Servers view, double click tomcat server.

image

Click Open launch configuration.

image

Click Arguments tab.

image

Add these two arguments:

-Djava.util.logging.config.file="TOMCAT_INSTALL/conf/logging.properties"
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

Save changes.

To set the log level of your own code, open TOMCAT_INSTALL/conf/logging.properties and add this line to the end:

com.mobiarch.test.level = FINE

This will set the log level for the com.mobiarch.test package to FINE.

Restart the server.

Now, your application code using JDK logging will start to show its messages in Eclipse console.

Logger logger = Logger.getLogger(getClass().getName());
logger.fine("Hello world");
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s