Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-511

API to flush appenders

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.2.15
    • 2.0.6
    • Appenders, Core
    • None
    • NA

    Description

      I would like to see an API that flushes any appenders that have buffered data. E.g. a method LogManager.Flush(). An application might call such a method at regular intervals, e.g. on a Timer.

      A naive implementation with the current log4net would iterate through appenders, looking for those that support flushing, and call the appender's flush method, e.g.:

      foreach (IAppender appender in
      LogManager.GetRepository().GetAppenders())

      { BufferingAppenderSkeleton bas = appender as BufferingAppenderSkeleton; if (bas != null) bas.Flush(); }

      But (a) I'm not sure this is thread-safe and (b) there are potentially other appenders that may want to be able to flush data (e.g. a TextWriterAppender with ImmediateFlush = false).

      The request consists of:

      • Add an interface, IFlushableAppender or equivalent, with a single method Flush().
      • Implement this interface in all relevant appenders (BufferingAppenderSkeleton, TextWriterAppender, ...)
      • Add a thread-safe static Flush() method to LogManager.

      Attachments

        Activity

          People

            Unassigned Unassigned
            joejoe Joe
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: