From: <Msc...@ao...> - 2003-01-28 17:48:12
|
In a message dated 1/28/03 7:52:16 AM Pacific Standard Time, md...@ji... writes: > Is there a relatively simple way to insert the message severity into > the Log::Dispatch::Email appender? > > For example, we want $log->debug("foo") to send an email with the > subject line "$0: [DEBUG] log email", $log->warn("bar") to have the > subject "$0: [WARN] log email", etc. > That's all up to the appender to define. Unfortunately, the currently available ones (Log::Dispatch::Email::MailSend etc.) all define the "subject" line at appender initialization time but won't allow you to modify it dynamically with every log request. What you could do (and that's actually easier than it sounds like at first) is write your own mail appender -- basically just one method that sends out the mail, using something like Mail::Send, that's it. Check out <A HREF="http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/FAQ.html#how_can_i_write_my_own_appender"> http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/F AQ.html#how_can_i_write_my_own_appender</A> on how to write the appender and keep in mind to use a package containing a ":" like "Log::Dispatch::MyMailAppender" and that the parameter hash coming in to log_message() carries an item "log4p_level" which is set to "ERROR" or "WARN" or whatever the level of the current message is. Does that sound reasonable? Any questions let me know. -- Mike Mike Schilli log...@pe... |