1Filter::Boolean(3)    User Contributed Perl Documentation   Filter::Boolean(3)
2
3
4

NAME

6       Log::Log4perl::Filter::Boolean - Special filter to combine the results
7       of others
8

SYNOPSIS

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

DESCRIPTION

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
48       combining 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

SEE ALSO

57       Log::Log4perl::Filter, Log::Log4perl::Filter::LevelMatch,
58       Log::Log4perl::Filter::LevelRange, Log::Log4perl::Filter::StringRange
59
61       Copyright 2002-2009 by Mike Schilli <m@perlmeister.com> and Kevin Goess
62       <cpan@goess.org>.
63
64       This library is free software; you can redistribute it and/or modify it
65       under the same terms as Perl itself.
66
67
68
69perl v5.12.2                      2010-08-31                Filter::Boolean(3)
Impressum