Apache Log4cxx
Version 1.6.0
|
Log4cxx supports multiple processes logging to the same file, providing you do not set the "Append" option to "false" (see log4cxx::FileAppender::setOption).
When the "Append" option is "true", each logging event (or buffered set of logging events) will be separate and contiguous in the log file. This is achieved by using "apr_file_write" which implements an OS dependent lock/write/unlock sequence during which the file pointer is moved the end of the file.
To coordinate rollover across multiple applications Log4cxx provides the log4cxx::rolling::MultiprocessRollingFileAppender. This appender ensures that only one of the Log4cxx-using processes performs the rollover process when the log file reaches its size limit.
Coordinating with other processes adds significant overhead compared to log4cxx::rolling::RollingFileAppender. Benchmark measurements show the overhead of this appender is more than 3 and 10 times the overhead of log4cxx::rolling::RollingFileAppender on Linux and Windows respectively. This overhead can be moved to a background thread by attaching the MultiprocessRollingFileAppender to an log4cxx::AsyncAppender.
This is an optional feature, and thus must be explicitly enabled by defining LOG4CXX_MULTIPROCESS_ROLLING_FILE_APPENDER=on when building Log4cxx.