23 #include <log4cxx/logger.h> 24 #include <log4cxx/basicconfigurator.h> 25 #include <log4cxx/xml/domconfigurator.h> 26 #include <log4cxx/propertyconfigurator.h> 27 #include <log4cxx/patternlayout.h> 28 #include <log4cxx/level.h> 29 #include <log4cxx/helpers/exception.h> 30 #include <log4cxx/rollingfileappender.h> 32 #include <boost/algorithm/string.hpp> 33 #include <boost/filesystem.hpp> 38 if (boost::filesystem::path(log4cxxConfPath).extension().
string() ==
".xml") {
39 log4cxx::xml::DOMConfigurator::configure(log4cxxConfPath);
42 log4cxx::PropertyConfigurator::configure(log4cxxConfPath);
47 INIT_LOGGERS(
const std::string& logDir,
const std::string& logLevel)
49 static bool configured =
false;
55 log4cxx::PatternLayoutPtr
56 layout(
new log4cxx::PatternLayout(
"%date{%s}.%date{SSS} %p: [%c] %m%n"));
58 log4cxx::RollingFileAppender* rollingFileAppender =
59 new log4cxx::RollingFileAppender(layout, logDir+
"/nlsr.log",
true);
61 rollingFileAppender->setMaxFileSize(
"10MB");
62 rollingFileAppender->setMaxBackupIndex(10);
64 log4cxx::helpers::Pool p;
65 rollingFileAppender->activateOptions(p);
67 log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(rollingFileAppender));
69 if (boost::iequals(logLevel,
"none")) {
70 log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getOff());
73 log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::toLevel(logLevel));
82 return boost::iequals(logLevel,
"all") || boost::iequals(logLevel,
"trace") ||
83 boost::iequals(logLevel,
"debug") || boost::iequals(logLevel,
"info") ||
84 boost::iequals(logLevel,
"warn") || boost::iequals(logLevel,
"error") ||
85 boost::iequals(logLevel,
"none");
bool isValidLogLevel(const std::string &logLevel)
void INIT_LOG4CXX(const std::string &log4cxxConfPath)
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California.
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California.
void INIT_LOGGERS(const std::string &logDir, const std::string &logLevel)