A custom filter provides optional, secondary control over what is logged, beyond the control that is provided by the level.
The mechanism for creating a customer filter is the Filter interface support that is provided by the IBM Developer Kit, Java Technology Edition. If you are not familiar with filters, as implemented by the Developer Kit, you can get more information from various texts, or by reading the API documentation the for java.util.logging API. The following example shows a custom filter:
import java.util.Vector; import java.util.logging.Filter; import java.util.logging.LogRecord; /** * MyCustomFilter rejects any log records whose Level is not contained in the * configured list of Levels. */ public class MyCustomFilter implements Filter { private Vector acceptableLevels; public MyCustomFilter(Vector acceptableLevels) { super(); this.acceptableLevels = acceptableLevels; } /* (non-API documentation) * @see java.util.logging.Filter#isLoggable(java.util.logging.LogRecord) */ public boolean isLoggable(LogRecord record) { return (acceptableLevels.contains(record.getLevel())); } }
Related reference
Logger hierarchy
java.util.logging custom log handlers
java.util.logging custom formatters
Custom handlers, filters, and formatters
Searchable topic ID: rtrb_createfilter