]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1622] some cleanups
authorJINMEI Tatuya <jinmei@isc.org>
Wed, 29 May 2013 22:57:27 +0000 (15:57 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Wed, 29 May 2013 22:57:27 +0000 (15:57 -0700)
src/lib/log/logger_manager_impl.cc

index f6f5bf154a2697965b4d86e9f5244466aff853c6..9fb4d570aea3dc8f9d109930edf2a859bb20ee1a 100644 (file)
@@ -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<string>(opt.maxsize));
         properties.setProperty("MaxBackupIndex",
                                lexical_cast<string>(opt.maxver));
-        properties.setProperty("ImmediateFlush", "true");
+        properties.setProperty("ImmediateFlush", opt.flush ? "true" : "false");
         properties.setProperty("UseLockFile", "true");
         fileapp = log4cplus::SharedAppenderPtr(
             new log4cplus::RollingFileAppender(properties));