Description
Reported by Salikh.Zakirov <Salikh.Zakirov@Intel.com>:
... I've noticed that autoflushing is not really implemented in Log4CXX.
I think that immediate flush behaviour is really needed for console appenders,
and it seems that by design it was meant to be that way:
writerappender defines immediateFlush as true, and
fileappander resets it to false for improving performance in buffered case.
The problem is that immediateFlush is never referenced on the write.
The following patch seemed to fix the problem.
===================================================================
— src/systemoutwriter.cpp (revision 463722)
+++ src/systemoutwriter.cpp (working copy)
@@ -35,6 +35,7 @@
}
void SystemOutWriter::flush(Pool& /* p */ )
{ + fflush(stdout); }void SystemOutWriter::write(const LogString& str, Pool& /* p */ )
{ Index: src/systemerrwriter.cpp =================================================================== --- src/systemerrwriter.cpp (revision 463722) +++ src/systemerrwriter.cpp (working copy) @@ -34,6 +34,7 @@ }void SystemErrWriter::flush(Pool& /* p */)
{ + fflush(stderr); }void SystemErrWriter::write(const LogString& str, Pool& /* p */)
{ Index: src/writerappender.cpp =================================================================== --- src/writerappender.cpp (revision 463722) +++ src/writerappender.cpp (working copy) @@ -197,6 +197,7 @@ LogString msg; layout->format(msg, event, p); writer->write(msg, p); + if (immediateFlush) writer->flush(p); }