logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: Adding Process ID + GID
Date Mon, 30 Aug 2004 17:24:35 GMT

On Aug 30, 2004, at 4:45 AM, Barak Simon wrote:

> Hi,
> 1. Could someone please advice me as to what's the best way to add a 
> flag to PatternLayout?
> I need to support Process ID (or is that already supported?), but wish 
> it to be runtime configurable like any other layout flag.

I thought of two different mechanisms that would be used by log4j to 
address the same issue.

Using a mapped diagnostic context or MDC appears to be implemented 
(mdc.cpp).  Somewhere early in your thread startup, you would make a 
call to MDC::put("ProcessID", pid) placing the process id in the MDC 
for the thread and you would use %X{ProcessID} format specifier to 
render the value.

The %t pattern can be used to output a thread id.  It appears that 
pattern parser will recognize that token, but does not implement 
anything to process it (patternparser.cpp).   I would assume that we 
are free to define the content of the thread id and that including the 
process id would be reasonable.

> 2. I also wish to support a global identifier per logging message - 
> what would be the best way to implement that within/on-top-of log4cxx?

Not sure exactly what you are wanting to do, but the MDC might be 
useful again.

View raw message