From: Mike S. <msc...@ao...> - 2003-09-21 23:36:43
|
Niles wrote: > Each of the appenders will have different minimum/maximum logging > levels. The Syslog-type one will log everything from INFO and above, > the DBI one will only log INFO, and the Email one will log ERROR and > above. Basically, the Syslog one is to capture all information, the > DBI one is to capture performance data, and the Email one is for > failure notification. > > The init file would contain items like > > log4perl.appender.A2.min_level = info > log4perl.appender.A2.max_level = info > log4perl.appender.A3.min_level = error I think what you've done might work, although we do it differently in Log4perl. Your "only INFO and above" cases are typically solved with "appender thresholds" and the "exactly INFO" case is typically done with a levelmatch filter. Here's two FAQs dealing with these tasks: http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/FAQ.html#i_want_to_log_error_and_warn_messages_to_different_files!_how_can_i_do_that http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/FAQ.html#how_can_i_collect_all_fatal_messages_in_an_extra_log_file > 3. Since the appenders have different purposes, instead of sending the > same message to multiple appenders (which is easy enough), I'd like to > send a hash reference to each appender, and have each appender format > the output in the way that's most appropriate for the appender. The > Syslog logger would create a line-oriented sendmail-type list of > equates, the DBI logger would write performance information to a > database table, and the Email appender would format the information in > a standard, human-readable fashion. Regarding the DBI logger, you might want to look at http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/Appender/DBI.html where Kevin has provided a more powerful interface for DBI interactions. In general, if you want the appender to perform some appender-specific filtering before it actually logs the message, just pick an appender which approximately does what you need (something in the Log::Dispatch hierarchy or an appender that comes with Log::Log4perl like Log::Log4perl::Appender::File), use it as a base class for your new appender and override its log() method. Additionally, if the data you want to pass around is of global nature, take a look at the MDC mechanism at http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/FAQ.html#how_can_i_include_global_(threadspecific)_data_in_my_log_messages Hope that helps, let us know if you have any more questions ... -- -- Mike Mike Schilli m...@pe... |