|
Suppressing Spring Logging
|
|
|
| |
September 1st 2009
|
I have a standalone Java program that uses Spring. When I ran it from the command line, by default, Spring spit out a ton of start-up log information. I wanted to suppress this - which to me sounded like a pretty easy/reasonable request. Not so.
My first bet was to make sure the log levels in my log4j.properties file were configured correctly. I adjusted them, and no luck. I next tried to override the log4j.properties file passing "-Dlog4j.configuration=myfile.properties" to the program. Again, nada.
Next, I poked around(here and here) and found that Spring uses Commons Logging by default to choose the logging implementation, and that I needed to make sure commons-logging.properties specified as:
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
This didn't work either. Ugh.
Finally, a colleague of mine suggested I check out FileMon and see what files were actually being touched when I ran my program. I did a filter for *logging* and found that it was actually using the JRE's logging.properties to drive the Spring start-up logs. WTF. So I needed to pass in...
-Djava.util.logging.config.file=mylogging.properties
...to my program, and it did in fact suppress the logs.
Why in the name of everything sacred and holy does logging need to be so freaking complicated. Can't we call a truce and just all use Log4J? Please!
|
|
I'm currently living in Pittsburgh, PA, working as a Senior Technical Consultant for Summa, and just finished up my Masters degree in Philosophy. (thesis here!) My blog is mostly on understanding how to better analyze, make, and influence decisions in the world of enterprise software development. Subscribe here or write me at ben_northrop at yahoo dot com.
|
Comments (1)
|