You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Mark Roder <mr...@wamnet.com> on 2001/10/02 04:58:24 UTC

Convention on name of log4j categories

One convention I have used in the past is to name my main log4j category of
a class "LOG".  It is shorter, reads a little easier, and even non log4j
users can understand what it is doing without learning what a Category is.
It is also easier to spell!

So this code in FaultableHandler would go from:

    static Category category =
            Category.getInstance(FaultableHandler.class.getName());

    public void undo(MessageContext msgContext) {
        category.debug("Enter: FaultableHandler::undo" );
        workHandler.undo( msgContext );
        category.debug("Exit: FaultableHandler::undo" );
    };

TO:

    static Category LOG =
            Category.getInstance(FaultableHandler.class.getName());

    public void undo(MessageContext msgContext) {
        LOG.debug("Enter: FaultableHandler::undo" );
        workHandler.undo( msgContext );
        LOG.debug("Exit: FaultableHandler::undo" );
    };


It also makes logic easier to read if there is more complex logic to be
opted in/out. Example:

...
    if (LOG.isDebugEnabled()){
        //longer code goes here
    }

Just a couple of cents thrown out there.


Later

Mark