|
JavaLog uses the GNU regular expression library to express runtime filtering patterns. Events are filtered in two passes. In the first pass, the event type is filtered using a Hashtable lookup. This is fast so that users can efficiently filter in and out event types that are not pertinent to the mode of operation of the software. In the second pass, other attributes of an event can be used in include/exclude criteria. This pass is slower since each include/exclude criterion is evaluated against each event. The remainder of this page describes how to filter JavaLog events at runtime using regular expressions.
JavaLog has two types of filtering - old and new. The old is being maintained for compatibility but it will eventually go away. The rest of this document describes the old style global event formatting. Go here for a description of the new runtime filter expression system.
Include filters are, by default, set to include everything, ".*", and exclude filters are, by default, set to exclude nothing, "". If an include filter is then set, it replaces the default ".*" pattern. Also, note that the default include filter is affected by the -Dlog=false properties. If this property is set false, the default include pattern is set to include nothing, ".*".
Compile time filtering is accomplished using the
Log.setEventsTypesToInclude(String filter)
and
setEventTypesToExclude(String filter)
functions of the Log.
Run time filtering is accomplished using the -Dlog.event.include=filters and -Dlog.event.exclude=filters properties.
java -Dlog.event.include="error.*" -Dlog.event.exclude="error1.*"would include all events whose type starts with "error" but then exclude those that started with "error1".
Log.log("1", "information"); Log.log("2", "information"); Log.log("4", "information"); Log.log("20", "debug"); Log.log("25", "detailed debug"); Log.log("26", "detailed debug"); Log.log("30", "super detailed debug");Then the using the command line filter -Dlog.events.include=filter, the user can filter these numeric levels to suit his debugging or logging needs. The following table illustrates some possibilities.
log.events.include | Included Event Types
[12] 2.
| 1, 2, 20, 25, 26
| 1 2.
| 1, 20, 25, 26
| [1-4] 2[5-9]
| 1, 2, 4, 25, 26
| |
Log.setFunctionsToInclude(String filter)
and
setFunctionsToExclude(String filter)
functions of the Log.
or at runtime using the properties
-Dlog.function.include=
filters
and
-Dlog.function.exclude=
filters properties.