[slf4j-user] logging a stack trace along with a parameterized string

Lowell Kirsh lowellk at gmail.com
Wed Dec 19 22:36:07 CET 2007


Thanks for the info. No big deal about having to concatenate those strings
like that - it's what I was used to until recently ;-)

On Dec 19, 2007 12:30 PM, Ceki Gulcu <listid at qos.ch> wrote:

>
> Hi Lowell,
>
> This is a well-known shortcoming of the SLF4J API. However, since
> exceptions are
> by definition rare, you can write
>
> LOG.debug("Got a "+e.getClass().getName()+" with value "+ e.getValue(),
> e);
>
> with an *infrequent* loss in performance. Of course, this form is also
> less
> pleasant to write, but again you write less of these.
>
> HTH,
>
> Lowell Kirsh wrote:
> > Looking at the API, I can't figure out how to log an exception's stack
> > trace along with a parameterized string. What I want is something like:
> >
> > ...
> > catch (FooException e) {
> >   LOG.debug("Got a {} with value {}", e.getClass().getName(),
> > e.getValue(), e);
> > }
> >
> > But it seems from the API that I can either pass a Throwable to the log
> > method, or some arguments to be interpolated into the String. Is there
> > an idiom for doing both?
> >
> > Thanks,
> > Lowell
>
>
> --
> Ceki Gülcü
> Logback: The reliable, generic, fast and flexible logging framework for
> Java.
> http://logback.qos.ch
> _______________________________________________
> user mailing list
> user at slf4j.org
> http://www.slf4j.org/mailman/listinfo/user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/slf4j-user/attachments/20071219/367afd20/attachment.htm>


More information about the slf4j-user mailing list