Mike Schilli wrote:
> There's a section in the Log4perl manual thattalks about this (not easy to
> find, though):
> http://search.cpan.org/~mschilli/Log-Log4perl-1.31/lib/Log/Log4perl.pm#Using_Log::Log4perl_with_wrapper_functions_and_classes
>
Thank you for the reply. :-)
Yes, I read that.
> Note that if you're using qw(:easy), you need to use
>
> package Helper;
> BEGIN {
> Log::Log4perl->wrapper_register(__PACKAGE__);
> };
> use Log::Log4perl qw(:easy);
That code doesn't work on my system:
2011-01-30 14:08:11 dpchrist@p43400e ~/sandbox
$ cat log4perl-helper.pl
#!/usr/bin/perl
package Helper;
BEGIN {
Log::Log4perl->wrapper_register(__PACKAGE__);
};
use Log::Log4perl qw(:easy);
2011-01-30 14:08:16 dpchrist@p43400e ~/sandbox
$ perl log4perl-helper.pl
Can't locate object method "wrapper_register" via package
"Log::Log4perl" (perhaps you forgot to load "Log::Log4perl"?) at
log4perl-helper.pl line 4.
BEGIN failed--compilation aborted at log4perl-helper.pl line 5.
Putting the 'use' statement before the 'BEGIN' statement makes Perl
happy, but %c still shows the Helper package, not 'main':
2011-01-30 14:22:44 dpchrist@p43400e ~/sandbox
$ nl log4perl-helper2.pl
1 #!/usr/bin/perl
2 package Helper;
3 use Log::Log4perl qw(:easy);
4 BEGIN {
5 Log::Log4perl->wrapper_register(__PACKAGE__);
6 };
7 sub help { DEBUG(__FILE__, __LINE__, ' ', @_) }
8 package main;
9 use Log::Log4perl qw(:easy);
10 Log::Log4perl->easy_init({layout=>'%c %m %n'});
11 DEBUG(__FILE__, __LINE__);
12 Helper::help(__FILE__, __LINE__);
2011-01-30 14:23:00 dpchrist@p43400e ~/sandbox
$ perl log4perl-helper2.pl
main log4perl-helper2.pl11
Helper log4perl-helper2.pl7 log4perl-helper2.pl12
Any suggestions?
David
2011-01-30 14:23:03 dpchrist@p43400e ~/sandbox
$ cat /etc/debian_version
5.0.8
2011-01-30 14:24:04 dpchrist@p43400e ~/sandbox
$ perl -v
This is perl, v5.10.0 built for i486-linux-gnu-thread-multi
Copyright 1987-2007, Larry Wall
Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
2011-01-30 14:24:06 dpchrist@p43400e ~/sandbox
$ perl -MLog::Log4perl -e 'print $Log::Log4perl::VERSION, "\n"'
1.31
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel