ok, LogEvent is an interface, but in core. And I'm coding the receivers against that interface, which says it returns a copy but does not in Log4jLogEvent:
* Get the MDC data.
* @return A copy of the Mapped Diagnostic Context or null.
By the way, the class javadoc for ThreadContext is incomplete or incorrect.
* The ThreadContext allows applications to store information either in a Map
So, I need a new API that doesn't return a copy? Or do I have to create a copy of an event when I add properties?
I'm confused. Although the javadoc could be better http://logging.apache.org/log4j/2.x/log4j-api/apidocs/org/apache/logging/log4j/ThreadContext.html#getContext() and http://logging.apache.org/log4j/2.x/log4j-api/apidocs/org/apache/logging/log4j/ThreadContext.html#getContext() both say they return a copy. ThreadContext doesn't have methods named getContextMap or getContextStack.Note that the LogEvent is not available in the API.RalphOn Aug 5, 2012, at 10:45 PM, Scott Deboy wrote:My point was really the contract in the API javadoc should be updated and we should implement that contract..if we neeed new APIs, that's ok..or if I'm forced to create a new Log4jevent I'll deal with the contract.
ScottOn Sun, Aug 5, 2012 at 9:32 PM, Ralph Goers <firstname.lastname@example.org> wrote:In the Log4j 2 API the getContext and cloneStack methods of ThreadContext return copies of the Map and Stack. In the LogEvent in impl getContextMap and getContextStack return the actual Map and Stack that are in the LogEvent. Copying them would be too expensive.
I don't know that there are any components yet that can add, delete or modify MDC keys or values, but i know that such a feature would be desired. That said, the RewriteAppender uses the RewritePolicy which creates a new LogEvent.
On Aug 5, 2012, at 7:16 PM, Scott Deboy wrote:
> Chainsaw and some Receivers add properties to events to support tracking, for example, log4jid is added by Chainsaw.
> One thing that needs to be clarified in the api contract is whether or not getContextMap and getContextStack give you a copy of the map/stack or the original, as again, Chainsaw and others will need to use some api to modify those values.
To unsubscribe, e-mail: email@example.com
For additional commands, e-mail: firstname.lastname@example.org