Question

I'm evaluating log4cplus for a multi threaded C++ application on linux. The TTCCLayout and the PatternLayout allow the thread name to be displayed. In my tests there was never a name but just a meaningless number. I'm not using the thread class of log4cplus. How does log4cplus determine this thread name and is it possible to set it myself?

Was it helpful?

Solution

Log4cplus (as of version 1.1.1 or earlier) does not have any PatternLayout formatter for thread names. It only has two thread related formatters:

  • %t - prints thread ID; for *nix, it is whatever value pthread_t represents, usually an int value or a pointer value

  • %T - prints alternative thread ID; for Linux, prints the value returned by syscall (SYS_gettid)

There is definitely some room for improvement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top