Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-286

FlushableAppender

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • None
    • logback-core
    • None
    • Operating System: Linux
      Platform: PC

    • 151

    Description

      Have appender implement the java.io.Flushable interface, or a logback-specific interface if preferred, so that we can call Appender.flush() to manually flush the appender's writer. Not all appenders would have this, only those that implement Flushable.

      This would be useful in the context where buffered IO is used, but we still want to ensure a flush is made at specific intervals. For instance, in development I create a Spring bean that listens to application events, and force-flushes logback after each http request has been processed by my application, ensuring that I always see all the error logs when something fails.

      I have accomplished by subclassing RollingFileAppender to implement Flushable, quite simply like this:
      public void flush() throws IOException

      { writer.flush(); }

      Attachments

        Activity

          People

            logback-dev Logback dev list
            bruno.navert Bruno Navert
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: