I think you have mis-understood nvivek's question. The FAQ entry you linked to covers the situation where due to the way log4perl is configured, and how multiple loggers interact with each other a single call to $log->warn('some message'); results in duplicate copies of a single message appearing.

I think nvivek has a different situation. He has written some code like this:

sub connect_to_service { my $service_url = shift; my $logger = Log::Log4perl->get_logger(); my $max_attempts = 10; ATTEMPT: while( $max_attempts-- ) { my $connection = connect($service_url, {timeout=>30}); if( defined $connection ) { $logger->info("Connected OK to $service_url"); return $connection; } else { $logger->error("Error connecting to $service_url, will ret +ry"); } } # If this line is reached then all 10 connection attempts failed $logger->logdie("Could not connect to $service_url"); }

nvivek wants to see in his logs something like this:

ERROR: Error connecting to soap//service, will retry [last message repeated 10 times] FATAL: Could not connect to soap//service

To do this, you would need to run a log::log4perl appender that retains state, and compares the current message with the previous one, and if they are similar enough would not log the message, but instead would increment an internal count. When it sees a different message it would then emit the last message repeated $n times message. (The appender could not simply compare for identical messages, because most layouts pretend log messages with date-stamps or the like.)

Unfortunately I don't know of an appender that fits this requirement, and I don't want to post the result of a google search without taking the time to understand it and make sure that it matches what the supplicant asked for.


In reply to Re^2: Log::Log4perl Module by chrestomanci
in thread Log::Log4perl Module by nvivek

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.