Tidy up your Java logging 1

Posted by Adrian O'Connor Mon, 28 Sep 2009 13:31:00 GMT

The logging libraries provided with Java 5 and above are pretty good, except they produce output that is almost unreadable. For example, consider the simplest example:

Logger logger = Logger.getLogger("PushServer");

logger.log(Level.SEVERE, "This is a sample message");

That produces the following log entry, on your screen and/or in a file:

Sep 28, 2009 9:30:48 PM javaloggersample.Main main
SEVERE: This is a sample message

Individually, that's OK, but 20 messages? Messy. 1000 messages? Pretty nasty. 100 threads each generating a stream of FINE messages? Yikes.

Categories

Code Spaces is an online development and collaboration service that includes: Subversion Hosting, Project Management, Work Items, Forums, and much more.

Check it out!


Syndicate

Archives



Powered by Olark