Cagao has asked for the wisdom of the Perl Monks concerning the following question:

I have an app that passes around a $log object, similar to an Log4Perl instance.

In addition to logging to a file, I'd also like a particular function to send it's log statements to an email.

Has anyone come across this before, or have any ideas on implementation? Or any existing modules that have something like this on offer?

  • Comment on Log to a file, but also log individual function to an email

Replies are listed 'Best First'.
Re: Log to a file, but also log individual function to an email
by fishmonger (Chaplain) on Jul 02, 2014 at 17:27 UTC
        Thanks for the suggestion. I will follow that advise next time.
Re: Log to a file, but also log individual function to an email
by Laurent_R (Canon) on Jul 02, 2014 at 20:12 UTC
    Just beware that, in some cases, sending an e-mail can be quite slow (and can slow down your application, if that matters), and, also, receiving too many e-mails leads to people just discarding them (or creating rules to send them to unwanted mails). You can log as many lines as you want through Log4Perl (although, here also, too much information might kill useful information), but receiving too many automatic emails is just a pain in the as*... hmm, well, in the neck. I get dozens of these automatic mails every day, I just no longer read them.
Re: Log to a file, but also log individual function to an email
by Discipulus (Canon) on Jul 03, 2014 at 07:27 UTC
    hello, i was in a similar situation last year: i looked at Log::Log4Perl and can do quite a lot of things.

    Finally i ended with Multiplexing log output: Log4perl of the poors in which you can find my best effort on multiplexing the log process.
    Here the 'debuglevel' dispatch table is ordered in an incremental manner: you can modify to act in a different way to add a MAIL specification.
    Take in count that the code is something experimental..

    HtH
    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.