Ben Northrop

  Thinking out loud about programming, decisions, philosophy...
...code ownership
Blog   |   Misc   |   CV   |   RSS    

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 am currently living in Pittsburgh, PA, working as a Senior Technical Consultant for Summa, and studying as a part-time graduate student in Philosophy at Carnegie Mellon University. My thoughts here are mostly on software development, but trying to take a few insights from philosophy, psychology, economics, and decision sciences to help us understand better why we do what we do...and how to do it better. I maintain two pet projects: codersCV and PMDReports. Check 'em out!




Got a Comment?

Name:
Website:
Are you human:
Comment:

Comments (0)


 None so far!