Commit 5da8f813 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[master] Merge branch 'trac1622'

parents 156c5f32 71007940
......@@ -5567,6 +5567,23 @@ TODO; there's a ticket to determine these levels, see #1074
If this is 0, no maximum file size is used.
Due to a limitation of the underlying logging library
(log4cplus), rolling over the log files (from ".1" to
".2", etc) may show odd results: There can be
multiple small files at the timing of roll over. This
can happen when multiple BIND 10 processes try to roll
over the files simultaneously.
Version 1.1.0 of log4cplus solved this problem, so if
this or higher version of log4cplus is used to build
BIND 10, it shouldn't happen. Even for older versions
it is normally expected to happen rarely unless the log
messages are produced very frequently by multiple
different processes.
......@@ -35,7 +35,10 @@
#include <log/logger_specification.h>
#include <log/buffer_appender_impl.h>
#include <boost/lexical_cast.hpp>
using namespace std;
using boost::lexical_cast;
namespace isc {
namespace log {
......@@ -121,21 +124,33 @@ 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.
LoggerManagerImpl::createFileAppender(log4cplus::Logger& logger,
const OutputOption& opt)
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) {
fileapp = log4cplus::SharedAppenderPtr(new log4cplus::FileAppender(
opt.filename, mode, opt.flush));
} else {
log4cplus::helpers::Properties properties;
properties.setProperty("File", opt.filename);
properties.setProperty("ImmediateFlush", opt.flush ? "true" : "false");
properties.setProperty("UseLockFile", "true");
fileapp = log4cplus::SharedAppenderPtr(
new log4cplus::RollingFileAppender(opt.filename, opt.maxsize,
opt.maxver, opt.flush));
new log4cplus::RollingFileAppender(properties));
// use the same console layout for the files.
......@@ -10,7 +10,7 @@ if USE_STATIC_LINK
AM_LDFLAGS += -static
CLEANFILES = *.gcno *.gcda
CLEANFILES = *.gcno *.gcda *.lock
EXTRA_DIST = log_test_messages.mes
BUILT_SOURCES = log_test_messages.h
......@@ -77,7 +77,11 @@ public:
// Destructor, remove the file. This is only a test, so ignore failures
~SpecificationForFileLogger() {
if (! name_.empty()) {
(void) unlink(name_.c_str());
// Depending on the log4cplus version, a lock file may also be
// created.
static_cast<void>(unlink((name_ + ".lock").c_str()));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment