Ralph Goers wrote:
I don't take offense at technical discussions on mailing lists. A lot
can get misinterpreted. Instead, I suggest you take a look at the code
and see if you think it is a horrible idea. What I'm currently actually
using, but would replace with this, does have more knowledge of Logback,
specifically so it can pass the objects to the Appender. Unfortunately
(at least I think so), SLF4J's LocationAwareLogger doesn't provide a
method to pass that information along.
I was meaning to ask. Why do you need support from LocationAwareLogger for
argument arrays if you are going to use logback-classic underneath SLF4J?
I assume an NDC is based on a ThreadLocal? This works well for data that
lasts the lifetime of the request in progress. It is dangerous to use
for data for a specific event as that data must be cleared after the
event is completed - without disturbing other data that might have been
stored in it.
Precisely. If push comes to shove, referring to my previous example using object
of type "Article", we could write
MDC.put("article", article); // push data
logger.info("article modified");
MDC.remove("article"); // mandatory clean up
However, this is less convenient than writing,
logger.info("article modified", article);
Note the lack of an anchor in the message. This is to emphasize that
we are using the argumentArray as an extension point, circumventing
usual message formatting. It is the responsibility of
"article"-specific appenders to process articles. This is similar to
the way MDC data is not always necessarily printed. In the previous
example, we are using the MDC as an extension point, albeit a clumsy
one.
Ralph
--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
_______________________________________________
logback-dev mailing list
[email protected]
http://qos.ch/mailman/listinfo/logback-dev