Tracking Down a Log4J Problem

I had a really interesting time tracking down a Log4J problem. We’ve been using Log4J for over a year now happily and even happier with the Commons Logging package on top of it. But last week (while I was on vacation) something went pear shaped: the logs got created but after some initial log messages got sent to the logs, no further messages would get logged. I checked the config file (the XML variety, not the properties file) and it was correct. I then set about digging through code to see if someone had programatically changed the logger, but found nothing. Finally today I found the culprit: a rogue file in a war file in our ear file (that had been there the whole time) had been changed to set the root logger to a level of WARN. Since all of our log messages are at INFO level, thus they never made it. I’ve tested this and it is indeed the problem.

That was a real pain to diagnose, especially since the offending file had not been checked into our source repository. Had it been checked in, I probably would have spotted the change sooner.