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.HandlerHigh-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 settingsAsyncFileHandler(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 voidclose()Close the handler and shutdown background thread Waits for all queued messages to be writtenvoidflush()Flush any buffered output Note: This waits for queue to drainintgetQueueCapacity()Get queue capacityintgetQueueSize()Get current queue size (for monitoring)booleanisQueueNearlyFull()Check if queue is nearly full (greater than 80%)voidpublish(java.util.logging.LogRecord record)Publish a log record asynchronously (non-blocking) Returns immediately after adding to queue
-
-
-
Constructor Detail
-
AsyncFileHandler
public AsyncFileHandler() throws java.io.IOExceptionCreates 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.IOExceptionCreates an async file handler with custom settings- Parameters:
pattern- Log file patternlimit- Maximum size per file in bytescount- 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:
publishin classjava.util.logging.Handler
-
flush
public void flush()
Flush any buffered output Note: This waits for queue to drain- Specified by:
flushin classjava.util.logging.Handler
-
close
public void close()
Close the handler and shutdown background thread Waits for all queued messages to be written- Specified by:
closein classjava.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
-
-