|
@@ -19,6 +19,7 @@
|
|
|
#include <log4cplus/configurator.h>
|
|
|
#include <log4cplus/consoleappender.h>
|
|
|
#include <log4cplus/fileappender.h>
|
|
|
+#include <log4cplus/syslogappender.h>
|
|
|
|
|
|
#include "log/logger_level_impl.h"
|
|
|
#include "log/logger_manager.h"
|
|
@@ -82,7 +83,7 @@ LoggerManagerImpl::processSpecification(const LoggerSpecification& spec) {
|
|
|
break;
|
|
|
|
|
|
case OutputOption::DEST_SYSLOG:
|
|
|
- createSyslogAppender(logger, *i);
|
|
|
+ createSysLogAppender(logger, *i);
|
|
|
break;
|
|
|
|
|
|
default:
|
|
@@ -134,6 +135,17 @@ LoggerManagerImpl::createFileAppender(log4cplus::Logger& logger,
|
|
|
logger.addAppender(fileapp);
|
|
|
}
|
|
|
|
|
|
+// SysLog appender.
|
|
|
+void
|
|
|
+LoggerManagerImpl::createSysLogAppender(log4cplus::Logger& logger,
|
|
|
+ const OutputOption& opt)
|
|
|
+{
|
|
|
+ log4cplus::SharedAppenderPtr syslogapp(
|
|
|
+ new log4cplus::SysLogAppender(opt.facility));
|
|
|
+ setSysLogAppenderLayout(syslogapp);
|
|
|
+ logger.addAppender(syslogapp);
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
// One-time initialization of the log4cplus system
|
|
|
|
|
@@ -194,5 +206,20 @@ void LoggerManagerImpl::setConsoleAppenderLayout(
|
|
|
appender->setLayout(layout);
|
|
|
}
|
|
|
|
|
|
+// Set the the "syslog" layout for the given appenders. This is the same
|
|
|
+// as the console, but without the timestamp (which is expected to be
|
|
|
+// set by syslogd).
|
|
|
+
|
|
|
+void LoggerManagerImpl::setSysLogAppenderLayout(
|
|
|
+ log4cplus::SharedAppenderPtr& appender)
|
|
|
+{
|
|
|
+ // Create the pattern we want for the output - local time.
|
|
|
+ string pattern = "%-5p [" + getRootLoggerName() + string(".%c] %m\n");
|
|
|
+
|
|
|
+ // Finally the text of the message
|
|
|
+ auto_ptr<log4cplus::Layout> layout(new log4cplus::PatternLayout(pattern));
|
|
|
+ appender->setLayout(layout);
|
|
|
+}
|
|
|
+
|
|
|
} // namespace log
|
|
|
} // namespace isc
|