How to subclass Log::Log4perl::Appender and Log::Dispatch::DBI

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I'm trying the following, to test if I can log to Oracle,
and am getting an error of:

Use of uninitialized value in numeric gt (>) at
/usr/lib/perl5/site_perl/5.8.5/Log/Log4perl/ line 160.
Can't use string ("level") as a HASH ref while "strict refs" in use at
/usr/lib/perl5/site_perl/5.8.5/Log/Log4perl/ line 187.

156:        my ($self, $p, $category, $level) = @_;

            DB<1> n
160:        if($self-> > $
161:                            Log::Log4perl::Level::PRIORITY) {

            DB<1> print $level

and $Log::Log4perl::Level::PRIORITY is undefined,
so I must be doing something wrong.

use Logger;
my $log = Logger->new();
# eventually want to use config file too..
# $log->init( 'dbi.conf' ); or Log::Log4perl::init( 'dbi.conf' );
for my $mth ( qw( debug info warn error fatal ) )
         $log->log( level => $mth, message => "Testing $mth" );

package Logger;

use base qw( Log::Log4perl );
sub new
         my $class = shift;

         my $dbh = getmyownconnection(); #from DBI->connect

         my $self =  Log::Log4perl::Appender->new(
                 name       => 'dbi',
                 dbh        => $dbh,
                 table      => 'my_log'

         return $self;

Essentially I want a class that will connect to the correct database
and write to the correct table, in Oracle.  Connecting to the DB is
Ok, but subclassing this isn't working the way I thought.
I also need to over-ride create_statement and log_message, but
that looks pretty simple.

I have found examples of other Log::Dispatch classes, but haven't
found anything that shows how to do it with ::DBI.

Site Timeline