Monday, April 03, 2006

Java - how to turn off Apache Commons Logging

Yippie, I'm working on a Java project at the moment!

I'm using a library that has lots of logging information using the Apache Commons Logging library (commons-logging-api.jar). I'm using JBuilder 2005 for this project, and I could see this huge stream of logging "info" being printed out in the messages window. I needed to turn this off so that I could better see my own output (which I'm currently doing using System.out.println). Here's how to do that:
java ... -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog MyClass
The dash should be directly in front of the D: -Dorg...

In my case, the command actually went:
C:\Borland\JBuilder2005\jdk1.4\bin\javaw -classpath "blah.jar" -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog MyClass

but you get the idea.

To get JBuilder to run this command, you go to Run -> Configurations and Edit the configuration you're using. In the Edit panel, under "VM parameters" type -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog. Messages all gone!

0 Comments:

Post a Comment

<< Home