Increasingly I'm turned off by Log4J and especially Apache Commons Logging. At the time I thought adding logging to the Java SDK was just one more way that the Java SDK was too bloated and becoming morbidly obese. I still think it needs a grand breakup in parts, but I now think that logging actually does belong in the SDK. A change in your logging API can affect ALL of your (well-written) code. It really belongs in the platform. While Log4J has an "appender advantage" and an "install base advantage" it is no longer the most obvious choice for logging unless you are using a platform that integrates it by default (I'd still suggest it for JBossAS 4.xx development). Having to deal with a library for something so core and its dependencies is a clear disadvantage. Commons logging is the worst, having two libraries that depend on different versions of commons anything is completely inefficient. This is especially true since Apache commons libraries tend to result in a massive suck of the rest of the commons libraries. More so because Tomcat's classloader is leakier than a faucet, which often means you use the version Tomcat wants to use or risk collision.
In nominal Java applications configuring Java logging is simple. Add this to the command line "-Djava.util.logging.config.file=logging.properties" and fill in logging properties to something like this:
#this example keeps all the logging from anything but your app
#to a minimum
#handlers
handlers=java.util.logging.ConsoleHandler,java.util.logging.FileHandler
# root logger should not talk much
.level = SEVERE
# the console shouldn't talk unless we say so
java.util.logging.ConsoleHandler.level = INFO
# Set the default logging level for new FileHandler instances
java.util.logging.FileHandler.level = ALL
# most of the bla goes to this file (in the startup dir by default)
java.util.logging.FileHandler.pattern=java.log
# Set the default formatter for new ConsoleHandler instances
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
# Set specific logging per packages
com.osintegrators.level = ALL
Increasingly my application development is not in straight Java and JBoss or not is an even mix. More and more I use Appcelerator (.org)(.com) which runs apps inside of Jetty for WAY more convenient debugging (JBoss never did figure out the .java edit without redeploying the whole thing). However, with Appcelerator apps, I was having a heck of a time getting at my server-side log. While Appcelerator logging and debugging is pretty good on the front end, my log messages seemed to go to /dev/null on the Jetty side. The trick was to edit $PROJECT/plugins/run_project.rb and add the -D to this line:
cmd = "java -Djava.util.logging.config.file=logging.properties -cp #{cp} #{props} org.appcelerator.endpoint.HTTPEndpoint #{port} \"#{webdir}\" \"#{servicesdir}\" #{scanperiod}"
Your logging.properties goes in $PROJECT. This lets you have your log and read it too!