src: Adding log4cxx logging
Refs: #1505
Change-Id: Ib154d91f81acf3f1dd8bbcf552062a16d03fec74
diff --git a/src/logger.cpp b/src/logger.cpp
new file mode 100644
index 0000000..c4a2f11
--- /dev/null
+++ b/src/logger.cpp
@@ -0,0 +1,28 @@
+#include <log4cxx/logger.h>
+#include <log4cxx/basicconfigurator.h>
+#include <log4cxx/patternlayout.h>
+#include <log4cxx/level.h>
+#include <log4cxx/helpers/exception.h>
+#include <log4cxx/rollingfileappender.h>
+
+#include "logger.hpp"
+
+void
+INIT_LOGGERS(const std::string& logDir)
+{
+ static bool configured = false;
+ if (configured) return;
+
+ log4cxx::PatternLayoutPtr
+ layout(new log4cxx::PatternLayout("%date{yyyyMMddHHmmssSSS} %c %L: %m%n"));
+ log4cxx::RollingFileAppender* rollingFileAppender =
+ new log4cxx::RollingFileAppender(layout, logDir+"/nlsr.log", true);
+ rollingFileAppender->setMaxFileSize("10MB");
+ rollingFileAppender->setMaxBackupIndex(10);
+ log4cxx::helpers::Pool p;
+ rollingFileAppender->activateOptions(p);
+ log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(rollingFileAppender));
+ log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getDebug());
+
+ configured = true;
+}