akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame^] | 1 | #include <log4cxx/logger.h> |
| 2 | #include <log4cxx/basicconfigurator.h> |
| 3 | #include <log4cxx/patternlayout.h> |
| 4 | #include <log4cxx/level.h> |
| 5 | #include <log4cxx/helpers/exception.h> |
| 6 | #include <log4cxx/rollingfileappender.h> |
| 7 | |
| 8 | #include "logger.hpp" |
| 9 | |
| 10 | void |
| 11 | INIT_LOGGERS(const std::string& logDir) |
| 12 | { |
| 13 | static bool configured = false; |
| 14 | if (configured) return; |
| 15 | |
| 16 | log4cxx::PatternLayoutPtr |
| 17 | layout(new log4cxx::PatternLayout("%date{yyyyMMddHHmmssSSS} %c %L: %m%n")); |
| 18 | log4cxx::RollingFileAppender* rollingFileAppender = |
| 19 | new log4cxx::RollingFileAppender(layout, logDir+"/nlsr.log", true); |
| 20 | rollingFileAppender->setMaxFileSize("10MB"); |
| 21 | rollingFileAppender->setMaxBackupIndex(10); |
| 22 | log4cxx::helpers::Pool p; |
| 23 | rollingFileAppender->activateOptions(p); |
| 24 | log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(rollingFileAppender)); |
| 25 | log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getDebug()); |
| 26 | |
| 27 | configured = true; |
| 28 | } |