1Appender::Limit(3)    User Contributed Perl Documentation   Appender::Limit(3)
2
3
4

NAME

6           Log::Log4perl::Appender::Limit - Limit message delivery via block period
7

SYNOPSIS

9           use Log::Log4perl qw(:easy);
10
11           my $conf = qq(
12             log4perl.category = WARN, Limiter
13
14                 # Email appender
15             log4perl.appender.Mailer          = Log::Dispatch::Email::MailSend
16             log4perl.appender.Mailer.to       = drone\@pageme.com
17             log4perl.appender.Mailer.subject  = Something's broken!
18             log4perl.appender.Mailer.buffered = 0
19             log4perl.appender.Mailer.layout   = PatternLayout
20             log4perl.appender.Mailer.layout.ConversionPattern=%d %m %n
21
22                 # Limiting appender, using the email appender above
23             log4perl.appender.Limiter              = Log::Log4perl::Appender::Limit
24             log4perl.appender.Limiter.appender     = Mailer
25             log4perl.appender.Limiter.block_period = 3600
26           );
27
28           Log::Log4perl->init(\$conf);
29           WARN("This message will be sent immediately.");
30           WARN("This message will be delayed by one hour.");
31           sleep(3601);
32           WARN("This message plus the last one will be sent now, seperately.");
33

DESCRIPTION

35       "appender"
36           Specifies the name of the appender used by the limiter. The
37           appender specified must be defined somewhere in the configuration
38           file, not necessarily before the definition of
39           "Log::Log4perl::Appender::Limit".
40
41       "block_period"
42           Period in seconds between delivery of messages. If messages arrive
43           in between, they will be either saved (if "accumulate" is set to a
44           true value) or discarded (if "accumulate" isn't set).
45
46       "persistent"
47           File name in which "Log::Log4perl::Appender::Limit" persistently
48           stores delivery times. If omitted, the appender will have no
49           recollection of what happened when the program restarts.
50
51       "max_until_flushed"
52           Maximum number of accumulated messages. If exceeded, the appender
53           flushes all messages, regardless if the interval set in
54           "block_period" has passed or not. Don't mix with
55           "max_until_discarded".
56
57       "max_until_discarded"
58           Maximum number of accumulated messages. If exceeded, the appender
59           will simply discard additional messages, waiting for "block_period"
60           to expire to flush all accumulated messages. Don't mix with
61           "max_until_flushed".
62
63       "appender_method_on_flush"
64           Optional method name to be called on the appender attached to the
65           limiter when messages are flushed. For example, to have the sample
66           code in the SYNOPSIS section bundle buffered emails into one,
67           change the mailer's "buffered" parameter to 1 and set the limiters
68           "appender_method_on_flush" value to the string "flush":
69
70                 log4perl.category = WARN, Limiter
71
72                     # Email appender
73                 log4perl.appender.Mailer          = Log::Dispatch::Email::MailSend
74                 log4perl.appender.Mailer.to       = drone\@pageme.com
75                 log4perl.appender.Mailer.subject  = Something's broken!
76                 log4perl.appender.Mailer.buffered = 1
77                 log4perl.appender.Mailer.layout   = PatternLayout
78                 log4perl.appender.Mailer.layout.ConversionPattern=%d %m %n
79
80                     # Limiting appender, using the email appender above
81                 log4perl.appender.Limiter              = Log::Log4perl::Appender::Limit
82                 log4perl.appender.Limiter.appender     = Mailer
83                 log4perl.appender.Limiter.block_period = 3600
84                 log4perl.appender.Limiter.appender_method_on_flush = flush
85
86           This will cause the mailer to buffer messages and wait for
87           "flush()" to send out the whole batch. The limiter will then call
88           the appender's "flush()" method when it's own buffer gets flushed
89           out.
90
91       If the appender attached to "Limit" uses "PatternLayout" with a
92       timestamp specifier, you will notice that the message timestamps are
93       reflecting the original log event, not the time of the message
94       rendering in the attached appender. Major trickery has been applied to
95       accomplish this (Cough!).
96

DEVELOPMENT NOTES

98       "Log::Log4perl::Appender::Limit" is a composite appender.  Unlike other
99       appenders, it doesn't log any messages, it just passes them on to its
100       attached sub-appender.  For this reason, it doesn't need a layout
101       (contrary to regular appenders).  If it defines none, messages are
102       passed on unaltered.
103
104       Custom filters are also applied to the composite appender only.  They
105       are not applied to the sub-appender. Same applies to appender
106       thresholds. This behaviour might change in the future.
107

LICENSE

109       Copyright 2002-2013 by Mike Schilli <m@perlmeister.com> and Kevin Goess
110       <cpan@goess.org>.
111
112       This library is free software; you can redistribute it and/or modify it
113       under the same terms as Perl itself.
114

AUTHOR

116       Please contribute patches to the project on Github:
117
118           http://github.com/mschilli/log4perl
119
120       Send bug reports or requests for enhancements to the authors via our
121
122       MAILING LIST (questions, bug reports, suggestions/patches):
123       log4perl-devel@lists.sourceforge.net
124
125       Authors (please contact them via the list above, not directly): Mike
126       Schilli <m@perlmeister.com>, Kevin Goess <cpan@goess.org>
127
128       Contributors (in alphabetical order): Ateeq Altaf, Cory Bennett, Jens
129       Berthold, Jeremy Bopp, Hutton Davidson, Chris R. Donnelly, Matisse
130       Enzer, Hugh Esco, Anthony Foiani, James FitzGibbon, Carl Franks, Dennis
131       Gregorovic, Andy Grundman, Paul Harrington, Alexander Hartmaier  David
132       Hull, Robert Jacobson, Jason Kohles, Jeff Macdonald, Markus Peter,
133       Brett Rann, Peter Rabbitson, Erik Selberg, Aaron Straup Cope, Lars
134       Thegler, David Viner, Mac Yang.
135
136
137
138perl v5.28.1                      2017-02-21                Appender::Limit(3)
Impressum