Class BufferedFileLogHandler

java.lang.Object
java.util.logging.Handler
io.github.connellite.logger.BufferedFileLogHandler

@Deprecated public class BufferedFileLogHandler extends Handler
Deprecated.
Not recommended for production. Draining the buffer opens and closes the file and holds a lock across those calls. Prefer FileLogHandler.
Handler that keeps formatted lines in a byte buffer and opens the log file only to drain that buffer. A drain runs from flush(), from close(), and when the buffer reaches FileLogHandlerConfig.bufferSize(). Optional rotation uses the same rules as FileLogHandler: size, calendar day, backup count, and gzip.

publish(java.util.logging.LogRecord), flush(), and close() hold lock. The file is not left open after a drain. close() drains the buffer, appends the formatter tail when this instance wrote the current segment, then ignores later records.

  • Constructor Details

    • BufferedFileLogHandler

      public BufferedFileLogHandler(Path logFile, FileLogHandlerConfig config)
      Deprecated.
    • BufferedFileLogHandler

      public BufferedFileLogHandler(Path logFile)
      Deprecated.
  • Method Details

    • publish

      public void publish(LogRecord record)
      Deprecated.
      Formats the record and appends it to the buffer. The file is opened only when the buffer reaches FileLogHandlerConfig.bufferSize(). Formatting runs before the lock, so a formatter failure does not drain or rotate.
      Specified by:
      publish in class Handler
    • flush

      public void flush()
      Deprecated.
      Drains the buffer into the log file. Does nothing when the buffer is empty or this handler is already closed.
      Specified by:
      flush in class Handler
    • close

      public void close()
      Deprecated.
      Drains the buffer, appends the formatter tail when this instance wrote the current segment, then ignores later records.
      Specified by:
      close in class Handler