Added variable to log4cxx configs

This commit is contained in:
HanzZ 2011-10-05 09:28:25 +02:00
parent b8dc29b0a8
commit 803c590d46
4 changed files with 13 additions and 4 deletions

View file

@ -1706,6 +1706,7 @@ int main(int argc, char **argv) {
p.load(istream);
p.setProperty("pid", boost::lexical_cast<std::string>(getpid()));
p.setProperty("jid", CONFIG_STRING(&config, "service.jid"));
log4cxx::PropertyConfigurator::configure(p);
}

View file

@ -1,7 +1,7 @@
log4j.rootLogger=debug, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/var/log/spectrum2/backends/backend-${pid}.log
log4j.appender.R.File=/var/log/spectrum2/${jid}/backends/backend-${pid}.log
log4j.appender.R.MaxFileSize=10000KB
# Keep one backup file

View file

@ -1,7 +1,7 @@
log4j.rootLogger=debug, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/var/log/spectrum2/spectrum2.log
log4j.appender.R.File=/var/log/spectrum2/${jid}/spectrum2.log
log4j.appender.R.MaxFileSize=10000KB
# Keep one backup file

View file

@ -20,9 +20,11 @@
#include <tchar.h>
#endif
#include "log4cxx/logger.h"
#include "log4cxx/consoleappender.h"
#include "log4cxx/patternlayout.h"
#include "log4cxx/propertyconfigurator.h"
#include "log4cxx/consoleappender.h"
#include "log4cxx/helpers/properties.h"
#include "log4cxx/helpers/fileinputstream.h"
#include "libgen.h"
#include <sys/stat.h>
@ -218,7 +220,13 @@ int main(int argc, char **argv)
#endif
}
else {
log4cxx::PropertyConfigurator::configure(CONFIG_STRING(&config, "logging.config"));
log4cxx::helpers::Properties p;
log4cxx::helpers::FileInputStream *istream = new log4cxx::helpers::FileInputStream(CONFIG_STRING(&config, "logging.config"));
p.load(istream);
p.setProperty("pid", boost::lexical_cast<std::string>(getpid()));
p.setProperty("jid", CONFIG_STRING(&config, "service.jid"));
log4cxx::PropertyConfigurator::configure(p);
}
#ifndef WIN32