[logback-user] logger option with string format, argument array and throwable

Merritt H Derr MDerr at nycm.com
Fri Jan 7 20:52:11 CET 2011

That works as you describe, with the format logger.debug(formatString, 
Object[]) where my formatString has placeholders for 6 parameters and 
there are 7 parameters in the Object[], where index 6 (the last one) has 
the exception as its object.. 

Thanks for the quick response


From:   Ceki Gulcu <ceki at qos.ch>
To:     logback-user at qos.ch
Date:   01/07/2011 12:50 PM
Subject:        Re: [logback-user] logger option with string format, 
argument array and throwable
Sent by:        logback-user-bounces at qos.ch

Hello Merritt,

I think this issue was fixed in SLF4J 1.6.0. The release notes state:

   In the presence of multiple parameters and if the last argument in a
   logging statement is an exception, then SLF4J will now presume that
   the user wants the last argument to be treated as an exception and not
   a simple parameter. See the relevant FAQ entry for further
   details. This fixes bug 70 submitted by Joern Huxhorn who also
   provided the relevant patch.

So in principle you should be able to write

   logger.debug("bad name {}", name, illegalArgumentException);

and logback should handle name as an argument and 
illegalArgumentException as an exception.

If that does not work, it's a bug which should be reported as a jira 


On 07.01.2011 17:36, Merritt H Derr wrote:
> This is for Logback 0.9.27.
> When logging using DBAppender, The argument fields in the database table
> logging_event are filled using the arguments from the log statement when
> used in for example the debug(String format, Object[] arguments) format.
> For the case where I want to log with a throwable included that would 
> in the logging_event_exception table, there is no debug method that will
> take a format, argument array and throwable, so I can't log using a 
> and argument array and hence, all the argument fields (Arg0, Arg1, Arg2,
> Arg3) are left blank in the logging_event table.
> Other than storing those arguments in the MDC for this case, is there
> another work around? Or am I just missing something simple?
> Thanks,
> Merritt Derr

Logback-user mailing list
Logback-user at qos.ch

Join us on Facebook at www.facebook.com/NYCMInsurance.

This email and any attachments to it are confidential and intended solely 
for the individual or entity to whom it is addressed. Any unauthorized 
review, use, disclosure or distribution is prohibited. If you have 
received this email in error, please contact the sender by reply email and 
destroy all copies of the original message. 

More information about the Logback-user mailing list