Wednesday, July 18, 2007

LOG4J configuration and JAR libraries gotcha!

I experienced unexpected behavior of LOG4J library. The problem was that I modified configuration of LOG4J and I added SMTPAppender but I forgot to distribute required JAR libraries (activation.jar and javamail.jar) into production.

The outcome was that LOG4J library was not initialized correctly and commons-logging library simply started to send INFO level messages to standard output (not to FileAppender and SMTPAppender). It is not that surprising, however; the problem is that I didn't have a chance to learn that LOG4J was not initialized due to missing JARs.

Is there any easy way to avoid such issues if Maven (or other options) can not be used and one have to rely just on Ant for particular project?

[Update]
I was thinking about this again and I think there should be a proper way how to learn about this issue - checking error output. I haven't had a chance to test this theory yet but I think this should be a way to go (assuming commons-logging does not swallow important messages).

2 comments:

3rojka said...

Do it as we do, write your own Appender, then you have full control of any exception.

Lukas said...

But LOG4J didn't fire any exception. If it did then I assume it would go to stdout anyway - so I would have learned about it.