logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Woods" <adam.wo...@rwwa.com.au>
Subject RE: Accessing a LoggingEvent's properties using a PatternLayout
Date Mon, 22 Sep 2008 05:10:24 GMT

>-----Original Message-----
>From: Curt Arnold [mailto:carnold@apache.org]
>Sent: Monday, 22 September 2008 11:47 AM
>To: Log4CXX User
>Subject: Re: Accessing a LoggingEvent's properties using a
>On Sep 21, 2008, at 8:11 PM, Adam Woods wrote:
>> Can anybody help me with this issue?
>> Is this a feature which was missed or is planned for a later release?
>> Your help is greatly appreciated.
>> Cheers,
>> Adam Woods
>> -----Original Message-----
>> From: Adam Woods [mailto:adam.woods@rwwa.com.au]
>> Sent: Wednesday, 17 September 2008 10:18 AM
>> To: log4cxx-user@logging.apache.org
>> Subject: Accessing a LoggingEvent's properties using a PatternLayout
>> Hello List,
>> I am trying to make use of the LoggingEvent's properties map so that

>> my
>> logs contain extra data specific to an event. This is implemented in
>> log4net, so I didn't think I would run into any problems.
>> However, on further investigation, the documentation and the code
>> suggest that there is no way to actually access the LoggingEvent's
>> properties using the PatternLayout's syntax.
>> Are the LoggingEvent's properties intended for this kind of use, or 
>> am I
>> going about this the wrong way?
>> Cheers,
>> Adam Woods
>The nomenclature gets a little muddied.  In log4j 1.2, there were no 
>properties just the NDC (nested diagnostic context) and MDC (mapped 
>diagnostic context) which were a thread-local stack and map, 
>respectively.  In the log4j 1.3 development (since abandoned), the 
>term MDC was changed to Properties in some places, but there was not a

>separation between the concepts .  log4cxx inherited from log4j 1.3 
>but appears to have separated MDC from Properties, though there is no 
>distinct API for injecting or using properties.  It does appear that 
>MDC works in the same manner as log4j 1.2, but "properties" appear to 
>be a non-functioning stub.
>I'm not an log4net expert, but it didn't seem to have a distinct 
>properties API vs an MDC API.  It just seems that MDC values are 
>stored in a member called Properties.
>What were you trying to do and what didn't appear to work in log4cxx 
>that did work in log4net?

Thanks for your reply Kurt.

In terms of what I am trying to do, a log4net wrapper has been written
and I've been tasked with doing a port to C++ (using log4cxx). The
log4net wrapper uses the properties map to store event related
information that can then be printed out in the logs. This is what I was
attempting to do when I was stopped by not being able to access the
properties. :-)

On further investigation (I must have missed this earlier), it seems
that the log4net MDC is synonymous with the properties dictionary.

My confusion came from the fact that log4cxx has two separate maps for
these, with no way to retrieve the properties from the PatternLayout.
You can insert into / retrieve properties from the properties map using
the LoggingEvent's APIs, there just seems to be no hook-up to the

Also, there does not seem to be any APIs in LoggingEvent which allow you
to insert into the MDC.

So I'm still confused :-)

Again, your help would be greatly appreciated.


1. The contents of this email and its attachments are confidential and privileged. Any unauthorised
use, or passing on, of the information to others who are not authorised is expressly prohibited.
If you receive this email in error, please advise us and then delete the email with any attachments.

2. Before opening or using attachments, check them for viruses and defects. The contents of
this email and its attachments may become scrambled, truncated or altered in transmission.
Please advise us of any anomalies.

3. Racing & Wagering WA's liability  is limited to resupplying the email and attached
files or the cost of having them resupplied.

4. The views represented in this email are those of the author and do not necessarily represent
those of Racing & Wagering WA unless this is clearly indicated.

View raw message