1Filter::Boolean(3) User Contributed Perl Documentation Filter::Boolean(3)
2
3
4
6 Log::Log4perl::Filter::Boolean - Special filter to combine the results
7 of others
8
10 log4perl.logger = WARN, AppWarn, AppError
11
12 log4perl.filter.Match1 = sub { /let this through/ }
13 log4perl.filter.Match2 = sub { /and that, too/ }
14 log4perl.filter.MyBoolean = Log::Log4perl::Filter::Boolean
15 log4perl.filter.MyBoolean.logic = Match1 ⎪⎪ Match2
16
17 log4perl.appender.Screen = Log::Dispatch::Screen
18 log4perl.appender.Screen.Filter = MyBoolean
19 log4perl.appender.Screen.layout = Log::Log4perl::Layout::SimpleLayout
20
22 Sometimes, it's useful to combine the output of various filters to
23 arrive at a log/no log decision. While Log4j, Log4perl's mother ship,
24 chose to implement this feature as a filter chain, similar to Linux' IP
25 chains, Log4perl tries a different approach.
26
27 Typically, filter results will not need to be passed along in chains
28 but combined in a programmatic manner using boolean logic. "Log if this
29 filter says 'yes' and that filter says 'no'" is a fairly common
30 requirement but hard to implement as a chain.
31
32 "Log::Log4perl::Filter::Boolean" is a special predefined custom filter
33 for Log4perl which combines the results of other custom filters in
34 arbitrary ways, using boolean expressions:
35
36 log4perl.logger = WARN, AppWarn, AppError
37
38 log4perl.filter.Match1 = sub { /let this through/ }
39 log4perl.filter.Match2 = sub { /and that, too/ }
40 log4perl.filter.MyBoolean = Log::Log4perl::Filter::Boolean
41 log4perl.filter.MyBoolean.logic = Match1 ⎪⎪ Match2
42
43 log4perl.appender.Screen = Log::Dispatch::Screen
44 log4perl.appender.Screen.Filter = MyBoolean
45 log4perl.appender.Screen.layout = Log::Log4perl::Layout::SimpleLayout
46
47 "Log::Log4perl::Filter::Boolean"'s boolean expressions allow for com‐
48 bining different appenders by name using AND (&& or &), OR (⎪⎪ or ⎪)
49 and NOT (!) as logical expressions. Parentheses are used for grouping.
50 Precedence follows standard Perl. Here's a bunch of examples:
51
52 Match1 && !Match2 # Match1 and not Match2
53 !(Match1 ⎪⎪ Match2) # Neither Match1 nor Match2
54 (Match1 && Match2) ⎪⎪ Match3 # Both Match1 and Match2 or Match3
55
57 Log::Log4perl::Filter, Log::Log4perl::Filter::LevelMatch,
58 Log::Log4perl::Filter::LevelRange, Log::Log4perl::Filter::StringRange
59
61 Mike Schilli, <log4perl@perlmeister.com>, 2003
62
63
64
65perl v5.8.8 2002-07-10 Filter::Boolean(3)