Log4cxx
  1. Log4cxx
  2. LOGCXX-156

immediate flush in console appender

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 0.10.0
    • Fix Version/s: 0.10.0
    • Component/s: Appender
    • Labels:
      None

      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); }

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Andreas Fester
            Reporter:
            Andreas Fester
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development