my $log MyLogger::->new("database"); is either a typo or the source of your problems, i can't tell which (you're missing a "=").

update: i've decided it's a typo :) and I've also decided that you should upgrade to the latest log4perl and that what you've posted pretty much works as it should, observe:

C:\dev\LOOSE>perl my $linguini = ' log4perl.logger.database = DEBUG, FileAppenderDatabase log4perl.logger.apache = DEBUG, FileAppenderApache ### APPENDERS ### log4perl.appender.FileAppenderDatabase= Log::Log4perl::Appende +r::File log4perl.appender.FileAppenderDatabase.filename=./database.log log4perl.appender.FileAppenderDatabase.mode= append log4perl.appender.FileAppenderApache= Log::Log4perl::Appende +r::File log4perl.appender.FileAppenderApache.filename= ./apache.log log4perl.appender.FileAppenderApache.mode= append ### LAYOUTS ### log4perl.appender.FileAppenderDatabase.layout=PatternLayout log4perl.appender.FileAppenderDatabase.layout.ConversionPattern=%d %p> + %F:%L [%P] %M - %m%n log4perl.appender.FileAppenderApache.layout=PatternLayout log4perl.appender.FileAppenderApache.layout.ConversionPattern=%d %p> % +C %F:%L [%P] %M - %m%n '; package MyLogger; # Wrapper class for Log::Log4perl. { use strict; use warnings; use fields; use Log::Log4perl; my $log; my $module_name; sub new { # initialize and return MyLogger object my MyLogger $self = shift; unless (ref $self) { $self = fields::new ($self); } $module_name = shift; if (!Log::Log4perl::initialized()) { Log::Log4perl->init(\$linguini ); $Log::Log4perl::caller_depth = 1; } $log = Log::Log4perl->get_logger($module_name); return $self; } sub debug{ # log a single message my ($self, $logmsg) = @_; $log->debug($logmsg); } } #Log::Log4perl->init("/opt/etc/log4perl.conf"); #my $log = Log::Log4perl->get_logger("database"); #$log->debug("blah blah"); my $log = MyLogger::->new("database"); $log->debug("blah blah"); $log = MyLogger::->new("apache"); $log->debug("blih blih"); __END__ C:\dev\LOOSE>cat database.log 2004/02/09 05:54:18 DEBUG> log.log4perl.bug.pl:61 [908] main:: - blah +blah 2004/02/09 05:54:40 DEBUG> log.log4perl.bug.pl:60 [728] main:: - blah +blah 2004/02/09 05:56:06 DEBUG> -:60 [1316] main:: - blah blah C:\dev\LOOSE>cat apache.log 2004/02/09 05:54:18 DEBUG> MyLogger log.log4perl.bug.pl:63 [908] main: +: - blih blih 2004/02/09 05:54:40 DEBUG> MyLogger log.log4perl.bug.pl:62 [728] main: +: - blih blih 2004/02/09 05:56:06 DEBUG> MyLogger -:62 [1316] main:: - blih blih C:\dev\LOOSE>

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.


In reply to Re: Wrapper class for log4perl redirects to wrong log file by PodMaster
in thread Wrapper class for log4perl redirects to wrong log file by andreas1234567

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.