[ 
https://issues.apache.org/jira/browse/LOGCXX-339?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13896620#comment-13896620
 ] 

Thorsten Schöning commented on LOGCXX-339:
------------------------------------------

I removed the wrong documentation but leave the bug open for now.

> Child thread does not inherit a copy of the mapped diagnostic context of its 
> parent
> -----------------------------------------------------------------------------------
>
>                 Key: LOGCXX-339
>                 URL: https://issues.apache.org/jira/browse/LOGCXX-339
>             Project: Log4cxx
>          Issue Type: Bug
>    Affects Versions: 0.10.0
>         Environment: Debian (Etch) Linux - x86 64-bit
>            Reporter: Ben Humphreys
>            Assignee: Curt Arnold
>            Priority: Minor
>
> The API documentation for MDC says "The MDC is managed on a per thread basis. 
> A child thread automatically inherits a copy of the mapped diagnostic context 
> of its parent."
> However this does not appear to be the case. Take the following testcase:
> #include <iostream>
> #include <pthread.h>
> #include <log4cxx/mdc.h>
> void *threadfunc(void *arg)
> {
>     std::cout << "child: " << log4cxx::MDC::get("mykey") << std::endl;
> }
> int main(int argc, char *argv[])
> {
>     pthread_t thread_id;
>     log4cxx::MDC::put("mykey", "123");
>     std::cout << "main: " << log4cxx::MDC::get("mykey") << std::endl;
>     pthread_create(&thread_id, NULL, threadfunc, NULL);
>     pthread_join(thread_id, NULL);
>     return 0;
> }
> This should return:
> main: 123
> child: 123
> But instead returns:
> main: 123
> child: 
> This behavior is noted in a more serious application where MDC is used to add 
> fields (such as hostname and MPI rank) to the logger output.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to