Skip to content
Snippets Groups Projects
Commit 2a24e426 authored by Jan David Mol's avatar Jan David Mol
Browse files

bug 1362: properly initialise Log4Cplus in every thread

parent a2fdf2de
No related branches found
No related tags found
No related merge requests found
......@@ -444,6 +444,9 @@ inline LoggerReference& getLogger() { return theirTraceLoggerRef; }
// @}
// initialise a new NDC (required when creating a new thread)
void initNDC();
// Initialize Log4cplus.
// \param propFile Name of the properties file. A missing \c ".log_prop"
// extension will automatically be added. Note that \a propFile is
......
......@@ -158,6 +158,10 @@ template <typename T> inline void Thread::stub(Args<T> *args)
// can be reused once the thread finishes.
Cancellation::ScopedRegisterThread rt;
#ifdef HAVE_LOG4CPLUS
initNDC();
#endif
try {
(args->object->*args->method)();
} catch (Exception &ex) {
......
......@@ -9,6 +9,14 @@ using namespace log4cplus;
namespace LOFAR
{
// Create an NDC (nested diagnostic context) with the text
// "application@node" and push it onto the NDC stack.
void initNDC(void)
{
string loggerId(basename(getExecutablePath()) + "@" + myHostname(false));
log4cplus::getNDC().push(loggerId);
}
namespace
{
// Define the eight trace log levels
......@@ -58,14 +66,6 @@ namespace LOFAR
return NOT_SET_LOG_LEVEL; // not found
}
// Create an NDC (nested diagnostic context) with the text
// "application@node" and push it onto the NDC stack.
void initNDC(void)
{
string loggerId(basename(getExecutablePath()) + "@" + myHostname(false));
log4cplus::getNDC().push(loggerId);
}
// Function that is used when the TRACE levels are NOT compiled out. It
// registers the TRACEn management routines at the Log4Cplus
// LogLevelManager and sets up the global trace-logger named "TRC", with
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment