views:

20

answers:

2

I've been having a frustrating time trying to sort out the logging in my project. In particular, one of the 3rd party libraries we use had one class, com.foo.bar.baz.java, that ignored any configuration in the properties file for the com.foo.bar package, instead following the application-wide properties.

Eventually using %c in the pattern layout I learned that Log4J was logging it as Windows rather than its package.

What could be causing this? It's proving remarkably Google-proof.

+1  A: 

There could be a lot of things causing it. Can you post your log configuration file? Do you have a gui project? Are you (or the 3rd party library) attempting to log to gui components?

Are you able to view the log4j configuration files of your 3rd party library?


To address your question of what could be causing this, on the surface, it sounds like they have created a custom logging implementation that is overriding your settings. There are lots of ways to achieve that.

For example, our application at work runs on Tomcat and there's a <logging> section in the server-config.xml file that allows one to specify a custom logging target for the server.

As another example, I've been bitten dozens of times by rogue commons-logging.properties files which can change the entire functionality of all logging, application wide, just by modifying a few properties. Further, those files specify a priority flag and if any property file is found on the classpath with a higher priority than the one in your project, it takes precedence!


Overall, there are lots of potential problems here. To be of more assistance, I would need a bit more information.

gmale
The logging isn't anything to do with GUI components, and the 3rd party library hasn't doesn't have it's own log4j.properties file. Its config file has an option for specifying which lo4j file to use - this is working properly as the majority of the library's logging is working as it should do.
Andy
Thanks to your questions I did take a closer look at the library's config file, and it turns out that it has a specific option to disable logging of the set of events that have been causing me problems. It's the only element with such an option, so I can only assume there's something odd about it behind the scenes.
Andy
Glad I could help in some way. Logging can get annoying sometimes because there are so many points of control. It's easy to spend lots of time debugging a perfectly good config file only to later find out that the config file has nothing to do with the problem. I've had a dependency turn off all logging in my application just because it referenced a certain SLF4J jar. It took 3 days to debug because, naturally, I first looked in all the wrong places!
gmale
+1  A: 

Don't forget that while the use of the fully qualified name of the class is the usual convention, it's not a requirement!

The author's quite at liberty to use whatever string they want as the Logger name and it sounds as if in this case, they've gone for a component based name.

Gwyn Evans