On 06/10/2013 08:08 PM, Jeremy C. Reed wrote:
> I noticed that I had a few processes still with open log files and when
> they logged they logged to the old log file instead of new file.
> This means that an admin may overlook it or, even worse, it may be
> rotated and lost.
Thank you for the problem report.
>
> Is this a feature?
This piece of code pre-dates my involvement. The old version of
log4cplus do not take multiple processes into account.
>
> Here is a workaround that seems to work for me:
>
> --- ./src/fileappender.cxx.orig 2013-06-07 11:43:19.000000000 -0500
> +++ ./src/fileappender.cxx 2013-06-07 11:45:06.000000000 -0500
> @@ -488,11 +488,13 @@
> void
> RollingFileAppender::append(const spi::InternalLoggingEvent& event)
> {
> - FileAppender::append(event);
>
> + // Rotate log file if needed before appending to it.
> if(out.tellp() > maxFileSize) {
> rollover(true);
> }
> +
> + FileAppender::append(event);
> }
It seems to me that we might need to extend the patch and add seek to
end of file before the roll condition and also to add second rotation
check after the FileAppender::append() call. The modified patch is
attached. I have committed this to both trunk and 1.1.x branches.
>
>
> This is with BIND10 which has many logging processes using a single
> log4cplus configuration. For information, see
> http://bind10.isc.org/ticket/1622#comment:34
> http://bind10.isc.org/ticket/2988
--
VZ
|