[logback-dev] implied Throwables

Ceki Gulcu listid at qos.ch
Mon Sep 3 23:10:31 CEST 2007


Hi Glen,

Thanks for sharing your idea. I think it makes sense. As you observer, the 
current API cannot deal with parameterized logging in conjunction with exceptions.

However, I do not think it's a serious limitation because:

1) when confronted with exceptions, the performance of evaluating whether to log 
or not is not that important (as you usually would want to log)

2) if for some odd reason you need the performance in case of exceptions, you 
can always write

if(logger.isErrorEnabled()) {
   logger.error("User name ["+name+"] does not match", exception);
}

In summary, although the current API is completely coherent, it meets most 
needs. More importantly, since logback's core logging API derives from SLF4J, we 
cannnot change logback's behavior without also changing SLF4J which I am not 
keen to do. :-)

Does the above make sense?



Glen Marchesani wrote:
> I love the project and am glad to see the new features added to logging 
> in general.
>  
> I am willing to write a patch for a feature but before I do I want to 
> make sure it is something you would be interested in.
>  
> There is no way to get a stack trace when using paramterized logging.  
> The patch I want to add is that if the last parameter is a Throwable 
> then it gets passed to the fitlerAndLog() method as a thorable (instead 
> of throwable being null).
>  
> To explain in code. 
> log.debug( "Something happened parm1={} parm2={} parm3={}", 1, 2, 3, new 
> Throwable() );
>  
>  
> This would not cause the Throwable to be logged.  So here are my questions
>  
> - if I added the code to ch.qos.logback.classic.Logger is that something 
> you are interested in?
>  
> - lacking that any recommendations on how to get this feature built in.
>  
>  
> Looking forward to your comments and thanks for the great work on a 
> great logging framework...
>  
> regards,
> Glen
>  
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> logback-dev mailing list
> logback-dev at qos.ch
> http://qos.ch/mailman/listinfo/logback-dev

-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch



More information about the logback-dev mailing list