Stubbisms – Tony’s Weblog

July 27, 2008

It’s time to let go of Commons Logging – Long Live SLF4J!

Filed under: Java — Tags: , , , , , — Antony Stubbs @ 2:04 am

I support the complete abandonment of Commons Logging in favour of Simple Logging Facade 4 Java (SLF4J). Especially in libraries that use it – I think it’s amazing that Spring to link to it in their libraries!

For those of you that are blissfully un-aware of the hazards of the run time binding that commons logging uses and have been luckily enough not to have run into it yet – educate yourselves.

“Commons-logging promises to bridge to different logging APIs such as log4j, Avalon logkit and java.util.logging API. However, it’s dynamic discovery mechanism is the source of painful bugs.”

Apparently it’s his fault. Well mostly, as he admits:

“I’ll come right out and admit it: commons-logging, at least in its initial form, was my fault, though probably not mine alone.”

This guy deserves a medal. He freely hosts a great service for Maven users (yay! go Maven! (and Ivy and Gradle for that matter) ) that let’s you deal away with Commons Logging in your project easily.

The summary of the solution is basically:

        <name>Version 99 Does Not Exist Maven repository</name>
    <!-- get empty jar instead of commons-logging -->

LogBack as mentioned in my previous post, along with SLF4J is a step into the recent present for logging technology (as opposed to living in pre-historic times of commons logging.

It’s really amaizing that something as seemingly simple as logging causes such a nightmare for so many people!


Maven issue MNG-1977 will address this issue nicely by letting you globally exclude all commons-logging dependencies across all transitive dependencies in one statement.

Please so your neighbor-hood developer a favour, and vote for it 🙂

July 15, 2008

Some serious logging niceness – Logback with Eclipse plugin

Filed under: Java — Tags: , , , — Antony Stubbs @ 12:25 am

I’ve just stumbled upon a new logging framework called Logback – I’d seen it before, but this time, someone I respect was switching to it, and someone he respects wrote an article on it which sums it up pretty nicely.

I especially take notice of the console Eclipse plugin – that’s what has made me download, install and try it out. And so far – nice. Serious nice.

The killer feature of the console plugin being two:

  1. Go to the java class and line where any given logging request was issued by double-clicking on its output line.
  2. Change the output format dynamically whenever you chose to do so.

And just for fun…


package org.tony.nathan.daniel.james;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ch.qos.logback.classic.util.LoggerStatusPrinter;

public class LogbackJavaTest {

	public static void main(String[] args) {

	    Logger log = LoggerFactory.getLogger(LogbackJavaTest.class);
	    log.debug( "Hello world." ); "interesting info" );
	    log.warn( "WARNING WILL ROBINSON!" );
	    log.error( "I'm sorry Dave..." );
	    try {
		throw new Exception("Holly crapo we're dying!" );
	    } catch (Exception e) {
		log.error( "Something bad happened", e);



package org.tony.nathan.daniel.james

import org.slf4j.Logger
import org.slf4j.LoggerFactory

import ch.qos.logback.classic.util.LoggerStatusPrinter

class LogBackGroovyTest {
	static void main(args) {

	    Logger log = LoggerFactory.getLogger(LogBackGroovyTest.class)
	    log.debug "Hello world." "interesting info"
	    log.warn "WARNING WILL ROBINSON!"
	    log.error "I'm sorry Dave..."
	    try {
			throw new Exception("Holly crapo we're dying!" )
		} catch (Exception e) {
			log.error( "Something bad happened", e)



package org.tony.nathan.daniel.james

import org.slf4j.{Logger,LoggerFactory}

import ch.qos.logback.classic.util.LoggerStatusPrinter

object LogBackScalaTest {

  val log = LoggerFactory getLogger(LogBackScalaTest getClass)
  log debug( "Hello world." )
  log info( "interesting info" )
  log warn( "WARNING WILL ROBINSON!" )
  log error( "I'm sorry Dave..." )
  try {
    throw new Exception( "Holly crapo we're dying!" )
  catch {
    case e => log.error( "Something bad happened", e)
  LoggerStatusPrinter printStatusInDefaultContext


Create a free website or blog at