Beta Optional maxMaximum age of log entries in milliseconds
Entries older than this age should be removed during cleanup. If not specified, no age-based cleanup is performed.
This can be changed at runtime to dynamically adjust retention.
// Retain logs for 7 days
store.maxAge = 7 * 24 * 60 * 60 * 1000;
// Retain logs for 1 hour
store.maxAge = 60 * 60 * 1000;
Optional maxMaximum number of log entries to retain
When the number of stored entries exceeds this limit, the oldest entries should be removed. If not specified, no entry-count limit is enforced.
This can be changed at runtime to dynamically adjust retention.
Optional minMinimum log level this handler should receive
If specified, the factory will only pass log entries with a level equal to or higher than this value. If not specified, all log entries are passed to the handler.
Level priority (lowest to highest): Debug → Info → Warn → Error
This can be changed at runtime to dynamically adjust filtering.
Handles a log entry
Implementations should handle their own errors internally to ensure reliability. However, any uncaught errors thrown by this method will be caught by the factory to prevent one handler from breaking others. Errors will be logged to the console but will not stop other handlers from receiving the log entry.
The log entry to handle
Extended handler interface for handlers that support log storage and retrieval
Handlers like memory and IndexedDB implement this interface to allow querying and exporting stored logs.
Remarks
Implementations should respect the configured retention policies (
maxEntriesandmaxAge) to prevent unbounded growth. These limits can be changed at runtime to dynamically adjust retention behavior.For high-volume logging, consider batching writes to reduce overhead.
Example