My program always crashes when I try to cache the LoggerPtr returned from
getLogger in a local static variable (i.e. singleton) like this:
LoggerPtr MyLogger()
{
static LoggerPtr singleton =
log4cxx::LogManager::getLogger("some.logger");
return singleton;
}
I assume this happens because of so
Try using the one parameter constructor for LoggerPtr, instead of the
default constructor and then an assignment:
static LoggerPtr
singleton(log4cxx::LogManager::getLogger("some.logger"));
There is a slight difference in order of events between the two.
Using the default constructor,
Thanks, I'll try.
But wouldn't it also make sense to just initialize APR before anything else
in the application (e.g. before configuring the log)?
Because this business with default vs. one-param constructor is very easy to
forget and get wrong (since both compile fine and it will only crash at
ru
Also, if assignment occurs separately from static initialization, then it
negates the whole reasoning for doing it with a static local variable (i.e.
that it only initializes once, and then returns the same object in
subsequent calls). So I would have to also check the static smart-pointer
for non-
I am using version 0.10.0 of log4cxx. This is basically what I do (note:
only the file name is
configured programmatically. The rest of the rollingfile appender is
configured using the xml file).
log4cxx::helpers::Pool p; // buffer pool that for activateOptions()
to use
FileAppenderPtr