Class DefaultAccessLogReceiver

java.lang.Object
io.quarkus.vertx.http.runtime.filters.accesslog.DefaultAccessLogReceiver
All Implemented Interfaces:
AccessLogReceiver, Closeable, AutoCloseable, Runnable

public class DefaultAccessLogReceiver extends Object implements AccessLogReceiver, Runnable, Closeable
Log Receiver that stores logs in a directory under the specified file name, and rotates them after midnight.

Web threads do not touch the log file, but simply queue messages to be written later by a worker thread. A lightweight CAS based locking mechanism is used to ensure than only 1 thread is active writing messages at any given time

Author:
Stuart Douglas
  • Constructor Details

    • DefaultAccessLogReceiver

      public DefaultAccessLogReceiver(Executor logWriteExecutor, File outputDirectory, String logBaseName)
    • DefaultAccessLogReceiver

      public DefaultAccessLogReceiver(Executor logWriteExecutor, File outputDirectory, String logBaseName, String logNameSuffix)
    • DefaultAccessLogReceiver

      public DefaultAccessLogReceiver(Executor logWriteExecutor, File outputDirectory, String logBaseName, String logNameSuffix, boolean rotate)
    • DefaultAccessLogReceiver

      public DefaultAccessLogReceiver(Executor logWriteExecutor, Path outputDirectory, String logBaseName)
    • DefaultAccessLogReceiver

      public DefaultAccessLogReceiver(Executor logWriteExecutor, Path outputDirectory, String logBaseName, String logNameSuffix)
    • DefaultAccessLogReceiver

      public DefaultAccessLogReceiver(Executor logWriteExecutor, Path outputDirectory, String logBaseName, String logNameSuffix, boolean rotate)
  • Method Details

    • logMessage

      public void logMessage(String message)
      Specified by:
      logMessage in interface AccessLogReceiver
    • run

      public void run()
      processes all queued log messages
      Specified by:
      run in interface Runnable
    • awaitWrittenForTest

      void awaitWrittenForTest() throws InterruptedException
      For tests only. Blocks the current thread until all messages are written Just does a busy wait.

      DO NOT USE THIS OUTSIDE OF A TEST

      Throws:
      InterruptedException
    • rotate

      public void rotate()
      forces a log rotation. This rotation is performed in an async manner, you cannot rely on the rotation being performed immediately after this method returns.
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • builder

      public static DefaultAccessLogReceiver.Builder builder()