Wednesday, July 07, 2010

jPitfalls - log4j adding through maven

One of the first thing a developer want to add is logging. Without logging there is no development. And i mean it... no development.. seriously!

Therefore i looked up in the net which logging Facility i should use and ended up with log4j. (And because all the Tutorials and Books i looked up used it as well). It's really great and flexible. (Enough advertising.)

But being not accustomed to Maven and Dependency Management and everything automatic, i had to learn another hard lesson.

The Thing with log4j is, there are several ways the output can be collected. Console, File, Database, you name it. The Thing with Maven and log4j is, if you add a plugin, it's automatically included and you don't even have to do much more work.

Being accustomed that every little peace has to be configured by hand i was unprepared for the *automaticallywedoeverythingforyou* world. Adding more than one log4j plugin i ended up with no output at all.

Nothing worked and i was starting to gave up my hopes. Fortunately a colleague of mine helped me out (we were sitting together, no clue at all) and found the reason for the misbehavior.

Use only the one output you need, no more than that and everything worked like a charm.

So today's Mantra is "Only use what you need, no more than that" (young grasshopper)

Thanks again

No comments: