1Appender::Limit(3) User Contributed Perl Documentation Appender::Limit(3)
2
3
4
6 Log::Log4perl::Appender::Limit - Limit message delivery via block period
7
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");
33
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 If the appender attached to "Limit" uses "PatternLayout" with a
64 timestamp specifier, you will notice that the message timestamps are
65 reflecting the original log event, not the time of the message
66 rendering in the attached appender. Major trickery has been applied to
67 accomplish this (Cough!).
68
70 "Log::Log4perl::Appender::Limit" is a composite appender. Unlike other
71 appenders, it doesn't log any messages, it just passes them on to its
72 attached sub-appender. For this reason, it doesn't need a layout
73 (contrary to regular appenders). If it defines none, messages are
74 passed on unaltered.
75
76 Custom filters are also applied to the composite appender only. They
77 are not applied to the sub-appender. Same applies to appender
78 thresholds. This behaviour might change in the future.
79
81 Copyright 2002-2009 by Mike Schilli <m@perlmeister.com> and Kevin Goess
82 <cpan@goess.org>.
83
84 This library is free software; you can redistribute it and/or modify it
85 under the same terms as Perl itself.
86
87
88
89perl v5.12.2 2010-08-31 Appender::Limit(3)