Logging in Java

One thing I have never understood is why people still insist on complicating logging in Java, now, almost a decade after Java got logging as part of the standard class library.  Logging is that one annoying thing that always means you need to fiddle a bit extra if you are integrating with certain libraries or frameworks.

I've heard a lot of incredibly stupid excuses for not using java.util.logging.  For instance if you object to the naming of the log levels you probably should find a different occupation.  Yes, they are stupid, but not impossibly so and there is nothing stopping you from extending them to something that is meaningful in your project.  To not use the standard mechanism for something because you object to an issue that BY DESIGN you can easily address is just plain un-intelligent.

Another complaint I often hear is that there is a lack of decent log handlers.  For instance log handlers that rotate log files etc.  Well, for eff's sake: write one then.  It takes you perhaps an hour to write a reasonably robust log handler that will rotate files, prune old files and even compress log files you aren't going to write more output to.  I've written a wide variety of log handlers for different uses over the years and the cumulative time it took me to write all of them is dwarfed by the amount of time I've had to spend dicking around with the clashes of differing logging religions.

I am not even going to talk about formatters since formatting an parsing information is beyond most programmers.  (No, really.  Designing formats that are meant to be parsed is generally not something you can expect even most seasoned programmers to do well).

If a fraction of the time spent on trying to make different logging libraries play nice with each other could be spent extending and adding to the standard logging mechanisms we'd have all manner of nice logging infrastructure based around java.util.logging now.

(Illustration in the top right corner is my opinion on the state of current "logging" technology :-)


  1. Take a quick look at The Other Side and marvel at the technology: http://msdn.microsoft.com/en-us/library/ff647733(v=PandP.10).aspx

  2. StaleD: Some things should remain unseen.

    Hmm. If you restructure the diagram somewhat and put the names of the various Schools of Logging in Java inside the boxes I believe this to be an accurate depiction of the low grade civil war that is Java logging.