Skip to content

_allAppenders cleanup, question / bug #2

Description

@Laro88

I am having a challenge with RollingFileAppender (inherting FileAppender) which is not released in my case.

I am looking at some code that has a "config reload" function on top of log4cpp, and it end up calling instantiateAllAppenders.

the _allAppenders contain pointers to appenders of various types, but they are not destroyed / cleaned in any way (when calling instantiateAllAppenders) leading the RollingFileAppender to be unable to rename the target logfile as there is an undeleted pointer to a RollingFileAppender.

 if (i2 == iEnd) {
     // a new appender
     currentAppender = appenderName;
     _allAppenders[currentAppender] = 
         instantiateAppender(configFilePath, currentAppender, logFileInstanceNbr);
 } else {
     throw ConfigureFailure(std::string("partial appender definition : ") + key);
 }

It acknowledge that this most likely is abuse of log4cpp calling instantiateAllAppenders, but but have to find a decent workaround this challenge.
I am considering using unique pointers to force a destructor call when the object become dangling, but I am unsure what the categories will have of side effects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions