I’ve just installed Log4J into a seperate project I’m working on at home (details of which will be forthcoming in the fullness of time!) and although I have a little bit of experience with setting it up at work, I don’t have a huge amount. But, this is one open source project that’s absolutely a doddle to setup.
If you’re writing a Java project (or for that matter, a PHP project as there is a sister project called Log4PHP too) and you want an easy to use, really customizable logging system then use Log4J because it really makes life easy. There’s heaps of example configurations you can lookup on the web if you get stuck, and if something goes wrong the Exceptions are actually meaningful.
Through the clever use of ‘Appenders’ (which are all specified in the configuration file which by default is log4j.properties) you can send your logging to Syslog (or Event Viewer in NT) a file, a rolling file (whereby when it reaches a certain size it’s automatically ‘rolled’ to a new file, with configurable amounts of files to leave behind etc), an SQL database using JDBC, a Swing log appender and goodness knows what else. These are log destinations that would normally take hours to program yourself.
The documentation for the project is awesome (and so is the Log4PHP project) which is a superb change for Open Source projects. Apache Projects certainly seem to lead the field when it comes to documentation, the lack of which in most O/S projects is something that I’ve lamented on many occasions. It’s interesting that I’m actually starting to enjoy working with Java again lately – and PHP (largely because of Smarty Template Engine as a lot of the software available is now starting to mature nicely.