logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: Enumerating Context properties.
Date Thu, 25 Aug 2005 11:28:15 GMT
The layered properties model in 1.2.9 has replaced the MDC model. The
MDC is emulated using ThreadContextProperties.

To get the properties map from the LoggingEvent use the
LoggingEvent.GetProperties() method. You should be able to iterate
through this in exactly the same way as before.

Cheers,
Nicko

> -----Original Message-----
> From: Zimney, Christopher M. [mailto:christopher.zimney@wamu.net] 
> Sent: 24 August 2005 22:18
> To: log4net-user@logging.apache.org
> Subject: Enumerating Context properties.
> 
> 
> Friends, 
> 
> When using 1.2.8, 
> 
> I created a custom Layout that enumerated the entries of the 
> MappedContext exposed by a LoggingEvent: 
> 
> // Append the MDC values if any exist
> if(loggingEvent.MappedContext != null && 
> loggingEvent.MappedContext.Count > 0) { 
>     foreach(DictionaryEntry entry in loggingEvent.MappedContext) 
>     { 
>         // xTxtWriter instantiated earlier as an XmlTestWriter 
>         xTxtWriter.WriteStartElement(entry.Key.ToString()); 
>         xTxtWriter.WriteString(entry.Value.ToString()); 
>         xTxtWriter.WriteEndElement(); 
>     }
> }
> 
> The result is something like this: 
> 
> <Context> 
>     <Entry1>Value1</Entry1> 
>     <Entry2>Value2</Entry2>
> </Context>
> 
> 
> In 1.2.9, the mapping is no longer exposed and I'm unsure how 
> to enumerate the entries of any of the new Context objects 
> (LogicalThreadContext, etc.)
> 
> Any ideas? 
> 
> 
> _____________ 
> Chris Zimney 
> WaMu Online 
> 206-461-4713 
> 
> 

Mime
View raw message