Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decreasing log level in Eclipse WTP with Tomcat 7

I am running Tomcat 7 from within Eclipse WTP (Juno) and I cannot seem to tune down the logging level. It logs everything from debug which is too verbose to be of any use (I want it log from INFO). The logging.properties file is as follows:

handlers =  java.util.logging.ConsoleHandler

.handlers = java.util.logging.ConsoleHandler

.level=INFO

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.  
############################################################

java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
like image 558
pgpython Avatar asked Jan 23 '13 14:01

pgpython


2 Answers

Adding both of these per the FAQ that Tom Chatt cites:

-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file="${workspace_loc}/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/logging.properties"

to the arguments to the server's launch configuration will get you what you want. ${workspace_loc} is literal; Eclipse will substitute it with your workspace directory. tmp0 may be tmp1 or such instead; use the same path that's in the server's configuration. Assumes that you've placed the logging.properties file there, of course. That way you'll see the file in the Project Explorer window under Servers. You should start by copying the one from the Tomcat conf directory.

This all assumes that you're intent on using JULI.

Works for me with Tomcat 8.0 and Eclipse Mars. No idea why it didn't work for Tom. I did see ClassNotFounds, for the obvious reason, when I used the wrong class name from someone's post.

I'd advise against the approach of Tom Chatt, since that will affect all of the other uses of that JVM.

like image 106
Mike Avatar answered Sep 20 '22 15:09

Mike


I had this same issue, wanting to configure the logging levels of Tomcat 7 in Eclipse WTP. I tried putting a logging.properties in the /src directory of my web app. No effect. I tried modifying the logging.properties file in the /conf directory of my Tomcat installation, but no effect there either. I discovered Eclipse WTP's "shadow" Tomcat area, under my workspace directory, in .metadata/.plugins/org.eclipse.wst.server.core/tmp0, and put a logging.properties file in the /conf directory under there. No effect.

I discovered a number of articles (e.g., this FAQ at eclipse.org) noting that while Tomcat in "real life" automatically runs with a logging manager called "JULI", for some reason the Tomcat running inside Eclipse WTP does not run with JULI. I tried adding

-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

to the VM args in my Tomcat run config, but that just got me ClassNotFound errors. (And yes, I did have tomcat-juli.jar in my classpath, so no idea why it wasn't finding it.)

Finally, it occurred to me to try modifying the logging.properties instance in my jdk jre/lib. Jackpot! It turns out that's the one that does have an effect on the logging done by Tomcat-in-Eclipse. So, the moral of this long tale is that if all you want to do is just simply configure the logging while you're running in Eclipse, with a simple little statement like:

myapp.mypackage.level=FINE

Then $JAVAHOME/lib/logging.properties is the place to put it.

like image 34
Tom Chatt Avatar answered Sep 17 '22 15:09

Tom Chatt