|
From: Mike S. <m...@pe...> - 2006-09-27 05:46:58
|
On Tue, 26 Sep 2006, Robert Jacobson wrote:
> At 02:18 PM 9/22/2006, John ORourke wrote:
> >I'd recommend writing another appender which wraps around
> >Appender::DBI and checks for availability.
>
> Ok, I've managed to write a basic wrapper (without checking for
> availability). It seems to work (i.e. messages are logged to the
> database), but in the Layout I'm using %F{2}, and I get
> "Log4perl/Logger.pm" instead of the path of my script. Do I need to
> mess with caller_depth or something?
If you're using wrapper classes, you need to adjust the caller level:
http://log4perl.sourceforge.net/d/Log/Log4perl.html#6acb7
-- Mike
Mike Schilli
m...@pe...
>
> ---------------------------------------------
>
> package Mylog;
>
> use warnings;
> use strict;
>
> require Log::Log4perl::Appender::DBI;
>
> sub new {
> my ($class, %options) = @_;
>
> my $appender = Log::Log4perl::Appender::DBI->new(
> map { $_ => $options{$_} } keys %options,
> );
>
> my $self = {
> appender => $appender,
> name => $options{name},
> };
>
> bless $self, $class;
>
> return $self;
>
> }
>
> sub log {
> my ($self, %p) = @_;
>
> $self->{appender}->log(
> %p,
> );
>
> return 1;
> }
>
> 1;
> ---------------------------------------------
>
> --
> Rob
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> log4perl-devel mailing list
> log...@li...
> https://lists.sourceforge.net/lists/listinfo/log4perl-devel
>
|