From: JINMEI Tatuya Date: Wed, 29 May 2013 22:57:27 +0000 (-0700) Subject: [1622] some cleanups X-Git-Tag: bind10-1.2.0beta1-release~418^2~6^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c1ca91c677addbb7a546ea8e36cc67e0717f1fb7;p=thirdparty%2Fkea.git [1622] some cleanups --- diff --git a/src/lib/log/logger_manager_impl.cc b/src/lib/log/logger_manager_impl.cc index f6f5bf154a..9fb4d570ae 100644 --- a/src/lib/log/logger_manager_impl.cc +++ b/src/lib/log/logger_manager_impl.cc @@ -124,12 +124,17 @@ LoggerManagerImpl::createConsoleAppender(log4cplus::Logger& logger, // File appender. Depending on whether a maximum size is given, either // a standard file appender or a rolling file appender will be created. +// In the case of the latter, we set "UseLockFile" to true so that +// log4cplus internally avoids race in rolling over the files by multiple +// processes. This feature isn't supported in log4cplus 1.0.x, but setting +// the property unconditionally is okay as unknown properties are simply +// ignored. void LoggerManagerImpl::createFileAppender(log4cplus::Logger& logger, const OutputOption& opt) { // Append to existing file - std::ios::openmode mode = std::ios::app; + const std::ios::openmode mode = std::ios::app; log4cplus::SharedAppenderPtr fileapp; if (opt.maxsize == 0) { @@ -142,7 +147,7 @@ LoggerManagerImpl::createFileAppender(log4cplus::Logger& logger, lexical_cast(opt.maxsize)); properties.setProperty("MaxBackupIndex", lexical_cast(opt.maxver)); - properties.setProperty("ImmediateFlush", "true"); + properties.setProperty("ImmediateFlush", opt.flush ? "true" : "false"); properties.setProperty("UseLockFile", "true"); fileapp = log4cplus::SharedAppenderPtr( new log4cplus::RollingFileAppender(properties));