From: Mike S. <m...@pe...> - 2008-11-06 23:06:56
|
On Thu, 6 Nov 2008, Mathieu Longtin wrote: > I have a program that processes a bunch of separate items, logging stuff as > it goes. I would like to be able to capture what gets logged during the > processing on one item, and email the whole thing if the processing failed. > The log messages should go to a file regardless. > > Is there a way to do that in log4perl currently? You could use one of the Log::Dispatch::Email::* modules on CPAN and set it to 'buffered': http://search.cpan.org/dist/Log-Log4perl/lib/Log/Log4perl/FAQ.pm#How_can_I_configure_Log::Log4perl_to_send_me_email_if_something_happens? When it is time to flush it, retrieve the appender by name and call its flush() method. But I'd probably just use Log4perl to write everything to a log file (use overwrite mode to start a new log file every time) and at the end of the program run a check and send off the logfile via a CPAN module like Mail::DWIM. -- Mike Mike Schilli m...@pe... |