You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Barak Simon <ba...@db.com> on 2004/08/30 11:45:30 UTC

Adding Process ID + GID

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.

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?

Many thanks,
Barak
________________________
Barak Simon
GED IT Core Platform
190 George St. Sydney, 2000
Phone +61 2 925 85070
Fax      +61 2 925 95050


--

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.



Re: Adding Process ID + GID

Posted by Curt Arnold <ca...@apache.org>.
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.