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

Ceki Gulcu ceki at qos.ch
Fri Jan 7 18:47:18 CET 2011


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 issue.

Cheers,

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 land
> 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 format
> 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





More information about the Logback-user mailing list