[Log4cplus-devel] problems displaying thread name (or understanding it)
Logging Framework for C++
Brought to you by:
wilx
From: Alexander D. <po...@le...> - 2013-05-14 12:48:55
|
Hei hei, I started playing around with log4cplus and wondered why I don't get thread names displayed. Before digging to deep in my own code I had a look at the test programs in the log4cplus source, namely thread_test. I compiled log4cplus 1.1.1 on an up to date Debian Wheezy without any special options when calling ./configure and get this (and more): % ./thread_test main Priority: NOTSET 0 [3049802608] WARN test.TestThread <> - Thread-3 TestThread.run()- Starting... 0 [3049802608] TRACE SlowObject <Thread-3 loop> - ENTER: SlowObject::doSomething() 1 [3049802608] INFO SlowObject <Thread-3 loop> - Actually doing something... 1 [3058195312] WARN test.TestThread <> - Thread-2 TestThread.run()- Starting... 1 [3058195312] TRACE SlowObject <Thread-2 loop> - ENTER: SlowObject::doSomething() 1 [3066588016] WARN test.TestThread <> - Thread-1 TestThread.run()- Starting... 1 [3066588016] TRACE SlowObject <Thread-1 loop> - ENTER: SlowObject::doSomething() 1 [3074980720] WARN test.TestThread <> - Thread-0 TestThread.run()- Starting... 2 [3074980720] TRACE SlowObject <Thread-0 loop> - ENTER: SlowObject::doSomething() 3 [3049802608] INFO SlowObject <Thread-3 loop> - Actually doing something...1, 2, 3, testing...DONE 3 [3058195312] INFO SlowObject <Thread-2 loop> - Actually doing something... 3 [3049802608] TRACE SlowObject <Thread-3 loop> - EXIT: SlowObject::doSomething() 3 [3049802608] TRACE SlowObject <Thread-3 loop> - ENTER: SlowObject::doSomething() 3 [3058195312] INFO SlowObject <Thread-2 loop> - Actually doing something...1, 2, 3, testing...DONE 3 [3066588016] INFO SlowObject <Thread-1 loop> - Actually doing something... The part in the <> seems to contain the thread name set in tests/thread_test/main.cxx line 100. Looking at layout.cxx a line in this layout starts with timestamp, has some thread info in square brackets, log level, logger name, NDC in <> and finally the message itself. This looks a little different than the example output on http://log4cplus.sourceforge.net/docs/html/classlog4cplus_1_1TTCCLayout.html which seems to have no number in square brackets but some name and no <> at all. What's the number in the square brackets? This question aims how I can set some kind of thread name without using the log4cplus thread class which is displayed with TTCC layout (or maybe PatternLayout), but maybe I should understand the example first. Greets Alex -- »With the first link, the chain is forged. The first speech censured, the first thought forbidden, the first freedom denied, chains us all irrevocably.« (Jean-Luc Picard, quoting Judge Aaron Satie) *** GnuPG-FP: 02C8 A590 7FE5 CA5F 3601 D1D5 8FBA 7744 CC87 10D0 *** |