Resolution: Won't Fix
Affects Version/s: 0.10.0
Fix Version/s: None
Environment:Debian (Etch) Linux - x86 64-bit
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:
void *threadfunc(void *arg)
std::cout << "child: " << log4cxx::MDC::get("mykey") << std::endl;
int main(int argc, char *argv)
std::cout << "main: " << log4cxx::MDC::get("mykey") << std::endl;
pthread_create(&thread_id, NULL, threadfunc, NULL);
This should return:
But instead returns:
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.