[log4perl-devel] Wrapper class question
Cees posted this on Perlmonks and it "works" but I get [undef] for
filename and line.
sub get_logger {
my $class = shift;
my $module_name = shift;
unless( Log::Log4perl->initialized ) {
# watch the config file for changes (in seconds)
Log::Log4perl->init_and_watch( "log4perl.conf", 60 );
$Log::Log4perl::caller_depth = 1;
}
return Log::Log4perl->get_logger( $module_name );
}
I am not calling it from a module but a "test.pl" file. It logs but I get:
[2007/08/21 12:39:21] [WARN] [[undef] line [undef]] This should go to
SCREEN and AMG.LOG
How do I change my wrapper to play nicely with Log4perl?
I am emailing here even though it says "devel" in the title since I
don't see a "users" anywhere. : )
Bob
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel
Re: [log4perl-devel] Wrapper class question
On Tue, 21 Aug 2007, Robert Hicks wrote:
> sub get_logger { my $class = shift; my $module_name = shift;
>
> unless( Log::Log4perl->initialized ) {
>
> # watch the config file for changes (in seconds)
> Log::Log4perl->init_and_watch( "log4perl.conf", 60 );
> $Log::Log4perl::caller_depth = 1;
> }
>
> return Log::Log4perl->get_logger( $module_name );
> }
You're increasing the caller_depth, although you're calling the log
method in the main program, not in the wrapper. Kick out that line and
you'll be ok.
-- Mike
Mike Schilli
[EMAIL PROTECTED]
>
> I am not calling it from a module but a "test.pl" file. It logs but I get:
>
> [2007/08/21 12:39:21] [WARN] [[undef] line [undef]] This should go to
> SCREEN and AMG.LOG
>
> How do I change my wrapper to play nicely with Log4perl?
>
> I am emailing here even though it says "devel" in the title since I
> don't see a "users" anywhere. : )
>
> Bob
>
>
> -
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> ___
> log4perl-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/log4perl-devel
>
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel
Re: [log4perl-devel] Wrapper class question
Mike Schilli wrote:
> On Tue, 21 Aug 2007, Robert Hicks wrote:
>
>> sub get_logger { my $class = shift; my $module_name = shift;
>>
>> unless( Log::Log4perl->initialized ) {
>>
>> # watch the config file for changes (in seconds)
>> Log::Log4perl->init_and_watch( "log4perl.conf", 60 );
>> $Log::Log4perl::caller_depth = 1;
>> }
>>
>> return Log::Log4perl->get_logger( $module_name );
>> }
>
> You're increasing the caller_depth, although you're calling the log
> method in the main program, not in the wrapper. Kick out that line and
> you'll be ok.
>
Ah! I was just reading up on caller_depth and that part was confusing me.
Robert
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel
