Hi there,
I work in a team and we're using SLF4J as logging system.
I've looked at the mailing list archive but I didn't find anything about the argument I'm going to explain: in the Logger interface, when you want to log a Throwable with its stack trace there is only one kind of method without arguments, so what you log is a (static) message and the exception stack trace. I/we think the availability of another method could be an enhancement. Often we need to log a format with arguments and an exception, so it would be useful a method like:

Logger.debug/info/warn/error(String format, Object[] args, Throwable t)

These methods could be added to the Logger interface.
We've realized an implementation of these methods for JDK 1.4 loggers; the attachment contains the implementation. It could be not too difficult to implement methods for others logging systems (log4j, jcl and so on).
Could it be an API enhancement?
Thank you in advance.
Hope to have not disturbed you.

Marco Cimatti
    public void debug(
            final String format, final Object[] args, final Throwable t) {
        if (isDebugEnabled()) {
            String msgStr = MessageFormatter.format(format, args);

            log(SELF, Level.FINE, msgStr, t);
        }
    }

    public void info(
            final String format, final Object[] args, final Throwable t) {
        if (isInfoEnabled()) {
            String msgStr = MessageFormatter.format(format, args);

            log(SELF, Level.INFO, msgStr, t);
        }
    }

    public void warn(
            final String format, final Object[] args, final Throwable t) {
        if (isWarnEnabled()) {
            String msgStr = MessageFormatter.format(format, args);

            log(SELF, Level.WARNING, msgStr, t);
        }
    }

    public void error(
            final String format, final Object[] args, final Throwable t) {
        if (isErrorEnabled()) {
            String msgStr = MessageFormatter.format(format, args);

            log(SELF, Level.SEVERE, msgStr, t);
        }
    }
_______________________________________________
user mailing list
[email protected]
http://www.slf4j.org/mailman/listinfo/user

Reply via email to