Class Log4j2AuditLogger

java.lang.Object
org.gridgain.internal.mcp.audit.Log4j2AuditLogger
All Implemented Interfaces:
AuditLogger

public class Log4j2AuditLogger extends Object implements AuditLogger
Log4j2-based audit logger with structured JSON output.

Features (all provided by Log4j2):

  • Asynchronous logging via AsyncLogger
  • JSON Lines format via JsonTemplateLayout
  • Automatic rotation via RollingFileAppender
  • Automatic cleanup via DefaultRolloverStrategy
  • Compression via .gz suffix in file pattern

All configuration is in log4j2-audit.xml. This class just writes structured data using ThreadContext.

  • Constructor Details

    • Log4j2AuditLogger

      public Log4j2AuditLogger(AuditConfiguration config)
      Constructs a new Log4j2 audit logger.
      Parameters:
      config - audit configuration (for validation)
  • Method Details

    • log

      public void log(AuditEvent event)
      Description copied from interface: AuditLogger
      Log an audit event asynchronously.

      Implementations should not block the caller. Events are typically queued and written in background threads.

      Specified by:
      log in interface AuditLogger
      Parameters:
      event - the audit event to log
    • flush

      public void flush()
      Description copied from interface: AuditLogger
      Flush any buffered audit events to persistent storage.

      Called during graceful shutdown to ensure no events are lost. Implementations should block until all pending events are written.

      Specified by:
      flush in interface AuditLogger
    • close

      public void close()
      Description copied from interface: AuditLogger
      Close the audit logger and release resources.

      Called during application shutdown. Should flush pending events and clean up any background threads or file handles.

      Specified by:
      close in interface AuditLogger