Hello,

I am new to log4cxx and have tried searching for an answer to my problem
to no avail.

My application uses log4cxx with different loggers and appenders
configured. Most of those appenders are rolling file appenders. I want
to obtain all of the files that are being written to by all the
different appenders in my system.

Here's what I do.
1. Program startup, reset the logger configuration:
LogManager::resetConfiguration()

2. Configure from a file:
PropertyConfigurator::configureAndWatch("myLogConfig",30000);

3. Attempt to obtain the list of all files being used by the appenders.

::log4cxx::LoggerPtr pLogger(log4cxx::Logger::getRootLogger());
::log4cxx::AppenderList appenders = pLogger->getAllAppenders();
for(::log4cxx::AppenderList::const_iterator iter = appenders.begin();
        iter != appenders.end();
        ++iter)
{
        ::log4cxx::FileAppenderPtr pFileAppender(*iter);
        if(pFileAppender != 0)
        {
                // Valid file appender
                std::string logFile(pFileAppender->getFile());

                // Do something with the file.....
        }
}

Unfortunately, appenders is always NULL and when this function exits, I
get an error when the AppenderList is destroyed.

Any help would be much appreciated,
Ryan

Reply via email to