From: Kevin G. <ke...@go...> - 2003-10-20 21:33:11
|
> I wonder if there is a way, using Log::Log4perl::Appender::DBI, to set a > value for a logger, which will be inserted at all subsequent log > statements. See 'Mapped Diagnostic Context' in the perldoc http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl.html#mapped_diagnostic_context_(mdc) > my $logger = Log::Log4perl::get_logger(); > > my $customer = get_cust_id(); #stash the value in a global location for the logger to find Log::Log4perl::MDC->put('customer', $customer); > do_something_dangerous() || $logger->error("Big problem !"); > # ... > do_something_uncredibly_dangerous() || $logger->error("Aaargh !"); And set up your appender to look like something this: log4j.appender.DBAppndr.sql = \ insert into logtable \ (custid, message) \ values (?,?) log4j.appender.DBAppndr.params.1 = %X{customer} Does that answer your question? -- Happy Trails . . . Kevin M. Goess (and Anne and Frank) 904 Carmel Ave. Albany, CA 94706 (510) 525-5217 |