com.ibm.mm.logging

Class AsyncFileHandler

  • java.lang.Object
    • java.util.logging.Handler
      • com.ibm.mm.logging.AsyncFileHandler


  • public class AsyncFileHandler
    extends java.util.logging.Handler
    High-performance asynchronous file handler for Java Util Logging Provides non-blocking logging with 10-50x better throughput than synchronous handlers Features: - Non-blocking publish (returns immediately) - Background thread for actual I/O - Bounded queue to prevent memory issues - Automatic file rotation - Graceful shutdown
    • Constructor Summary

      Constructors 
      Constructor and Description
      AsyncFileHandler()
      Creates an async file handler with default settings
      AsyncFileHandler(java.lang.String pattern, int limit, int count)
      Creates an async file handler with custom settings
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void close()
      Close the handler and shutdown background thread Waits for all queued messages to be written
      void flush()
      Flush any buffered output Note: This waits for queue to drain
      int getQueueCapacity()
      Get queue capacity
      int getQueueSize()
      Get current queue size (for monitoring)
      boolean isQueueNearlyFull()
      Check if queue is nearly full (greater than 80%)
      void publish(java.util.logging.LogRecord record)
      Publish a log record asynchronously (non-blocking) Returns immediately after adding to queue
      • Methods inherited from class java.util.logging.Handler

        getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AsyncFileHandler

        public AsyncFileHandler()
                         throws java.io.IOException
        Creates an async file handler with default settings
        Throws:
        java.io.IOException - if unable to create log files
      • AsyncFileHandler

        public AsyncFileHandler(java.lang.String pattern,
                                int limit,
                                int count)
                         throws java.io.IOException
        Creates an async file handler with custom settings
        Parameters:
        pattern - Log file pattern
        limit - Maximum size per file in bytes
        count - Number of files to keep
        Throws:
        java.io.IOException - if unable to create log files
    • Method Detail

      • publish

        public void publish(java.util.logging.LogRecord record)
        Publish a log record asynchronously (non-blocking) Returns immediately after adding to queue
        Specified by:
        publish in class java.util.logging.Handler
      • flush

        public void flush()
        Flush any buffered output Note: This waits for queue to drain
        Specified by:
        flush in class java.util.logging.Handler
      • close

        public void close()
        Close the handler and shutdown background thread Waits for all queued messages to be written
        Specified by:
        close in class java.util.logging.Handler
      • getQueueSize

        public int getQueueSize()
        Get current queue size (for monitoring)
        Returns:
        Number of log records waiting to be written
      • getQueueCapacity

        public int getQueueCapacity()
        Get queue capacity
        Returns:
        Maximum queue size
      • isQueueNearlyFull

        public boolean isQueueNearlyFull()
        Check if queue is nearly full (greater than 80%)
        Returns:
        true if queue is nearly full
Copyright © 2024 IBM Corporation

Copyright © 2024 IBM Corporation. All rights reserved.