Re: [log4perl-devel] Can caller_depth be set per logger
Thanks for the reply Kevin.
Kevin M. Goess wrote:
> Martin,
>
> Have you tried something like this? It would go in each wrapper method
> in your st.pm and db.pm, at the beginning of the method:
>
> local $Log::Log4perl::caller_depth =
>$Log::Log4perl::caller_depth + 2;
I should have said I knew I could do this but a) there are an awful lot
of methods b) when logging is not enabled each method has the overhead
of the above statement for nothing.
> It's a package variable, so no, there is no other way to set it per-logger.
Shame.
> There's some discussion of this in the FAQ ("perldoc Log::Log4perl::FAQ").
I haven't yet looked at the code - do you know how difficult it would be
to make caller_depth per logger?
Martin
--
Martin J. Evans
Easysoft Limited
http://www.easysoft.com
> Martin J. Evans wrote:
>> Hi,
>>
>> I mailed this question some months ago and did not get any response so I
>> thought I'd have one last go slightly reworded.
>>
>> I have many different loggers in the same application in the program
>> itself and various modules. One module is a wrapper class around DBI and
>> has to set the caller_depth to 2 but caller_depth seems to be global and
>> hence this affects all other loggers in the same program. Is there any
>> way to set caller_depth per logger?
>>
>> My precise example was in my post on this list 3-dec-07.
>>
>> Thanks
>>
>> Martin
>
>
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel
Re: [log4perl-devel] log4perl question
On Wed, 6 Feb 2008, Kevin M. Goess wrote:
> If you want to send "info" messages too, then do this, changing ERROR
> to INFO:
>
> log4perl.rootLogger=INFO, LOGFILE
>
> That will send all messages of level "info", "warn", "error" and "fatal"
> to your LOGFILE.
... and just in case: if you want to capture INFO messages in one file,
and ERROR messages in another, here's the answer to that:
http://log4perl.sourceforge.net/d/Log/Log4perl/FAQ.html#c7fa8
-- Mike
Mike Schilli
[EMAIL PROTECTED]
>
> Does that answer your question?
>
> Fernando Sousa wrote:
> > Hi all,
> >
> > probably you can give some help on this topic.
> > I'm using the Log-Log4perl-1.14 and I've initialize the following
> > log.conf file:
> >
> > [root@ test]# cat log.conf
> > ##
> > ##
> > # A simple root logger with a Log::Log4perl::Appender::File
> > # file appender in Perl.
> >
> >
> > log4perl.rootLogger=ERROR, LOGFILE
> >
> > log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
> > log4perl.appender.LOGFILE.filename=/tmp/myerrs.log
> > log4perl.appender.LOGFILE.mode=append
> >
> > log4perl.appender.LOGFILE.layout=PatternLayout
> > log4perl.appender.LOGFILE.layout.ConversionPattern=%d %p> %F{1}:%L %M - %m%n
> >
> >
> > With this setup, log4perl will catch all Errros and stores it at
> > /tmp/myerrs.log file.
> > My intention is to capture ERRORs and also the INFOs traces.
> > Something like "log4perl.rootLogger=ERROR and INFO, LOGFILE".
> >
> > Is it possible to do ?? if yes, how it does??
> >
> >
> > Best Regards,
> > Fernando
> >
> >
> >
> >
> > -
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2008.
> > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> >
> >
> >
> >
> > ___
> > log4perl-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/log4perl-devel
>
>
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> ___
> log4perl-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/log4perl-devel
>
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel
Re: [log4perl-devel] Can caller_depth be set per logger
>> local $Log::Log4perl::caller_depth =
>>$Log::Log4perl::caller_depth + 2;
>
> I should have said I knew I could do this but a) there
> are an awful lot of methods b) when logging is not
> enabled each method has the overhead of the above
> statement for nothing.
Well, that's true, but the overhead is dwarfed by what it's already
costing you to subclass the DBI methods. On my box I can process
196,002 child-method calls per second, and that decreases to 176,991
calls per second when adding the manipulation of $caller_depth. On the
other hand, calling the parent method would have run at 1,689,189 per
second.
And you could probably improve the performance of manipulating
$caller_depth by skipping it unless $h->{logger}->is_debug is true.
call_local: 3 wallclock secs ( 1.92 usr + 0.00 sys = 1.92 CPU) @
2604166.67/s (n=500)
child_with_local: 29 wallclock secs (28.19 usr + 0.06 sys = 28.25 CPU)
@ 176991.15/s (n=500)
childmethod: 26 wallclock secs (25.47 usr + 0.04 sys = 25.51 CPU) @
196001.57/s (n=500)
supermethod: 3 wallclock secs ( 2.95 usr + 0.01 sys = 2.96 CPU) @
1689189.19/s (n=500)
use strict;
use Benchmark;
$Log::Log4perl::caller_depth = 0;
{ package testpackage;
sub runmethod {}
}
{ package child::testpackage;
push our @ISA, 'testpackage';
sub runmethod {
my($sth, @args) = @_;
my $h = $sth->{private_DBIx_Log4perl};
my $res = $sth->SUPER::runmethod(@args);
}
#the same thing, but with a local() call added
sub runmethod_with_local {
my($sth, @args) = @_;
local $Log::Log4perl::caller_depth =
$Log::Log4perl::caller_depth + 2
if ;
my $h = $sth->{private_DBIx_Log4perl};
my $res = $sth->SUPER::runmethod(@args);
}
}
my $dbh = {};
bless $dbh, 'testpackage';
my $dbhX = {private_DBIX_Log4perl => 1};
bless $dbhX, 'child::testpackage';
my @args = (1,2,3);
timethese( 500, {
supermethod => sub { $dbh->runmethod(@args) },
childmethod => sub { $dbhX->runmethod(@args) },
child_with_local => sub { $dbhX->runmethod_with_local(@args) },
call_local => sub { local $Log::Log4perl::caller_depth =
$Log::Log4perl::caller_depth + 2; },
});
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel
