I would like to read in a configuration file to log4cxx, but during runtime, I would like to modify the appenders/loggers. Can I do this?
Example log4cxx file:
log4j.rootLogger=all, console, file
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.SimpleLayout
log4j.appender.console.threshold=info
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %c [%p] %l %m%n
log4j.appender.file.filename=logfile.txt
log4j.appender.file.datePattern='.'yyyy-MM-dd
Example source:
PropertyConfigurator::configure("./LoggingConfig.txt");
auto rootlogger = Logger::getRootLogger();
DailyRollingFileAppenderPtr fileappender = rootlogger->getAppender(LOG4CXX_STR("file"));
fileappender->setFile(LOG4CXX_STR("thisisthenewfile.txt"));
--I've noticed that the output still writes to the original location in my configuration file.
Is it not possibly to configure using code (runtime) as well as a file?