[log4perl-devel] $Log::Log4perl::caller_depth, layout %c and %T, and category

2011-01-24 Thread David Christensen
log4perl-devel:

I'm a new Log::Log4perl user and am trying to create some Log4perl 
helper logger functions.


I've found that:

 $Log::Log4perl::caller_depth


seems to affect the following layout placeholders:

 %C Fully qualified package (or class) name of the caller

 %l Fully qualified name of the calling method followed by the
callers source the file name and line number between
parentheses.

 %L Line number within the file where the log statement was issued

 %M Method or function where the logging request was issued

but it does not seem to affect the following layout placeholders:

 %c Category of the logging event

 %T A stack trace of functions called

nor the following argument to easy_init():

 category


How do I write a helper function that does affect %c, %T, and category 
-- e.g. so that calls to my helper logger functions are handled by 
Log::Log4perl the same way that calls to Log::Log4perl logger functions 
are handled?


TIA,

David



2011-01-23 14:30:18 dpchrist@p43400e ~/sandbox
$ cat log4perl-easy
#!/usr/bin/perl

$! = 1;

#
package Foo;
#
use strict;
use warnings;
use Log::Log4perl qw(:easy);
sub foo {
 DEBUG(   @_, 'foo', __LINE__);
 Helper::help(@_, 'foo', __LINE__);
}

###
package Helper;
###
use strict;
use warnings;
use Log::Log4perl qw(:easy);
sub help
{
 local $Log::Log4perl::caller_depth =
 $Log::Log4perl::caller_depth + 1;
 DEBUG(@_, 'help', __LINE__);
}

#
package main;
#
use strict;
use warnings;
use Log::Log4perl qw(:easy);

Log::Log4perl->easy_init( {
 layout => '%%c %c %n'
 . '%%C %C %n'
 . '%%d %d %n'
 . '%%F %F %n'
 . '%%H %H %n'
 . '%%l %l %n'
 . '%%L %L %n'
 . '%%m %m %n'
 . '%%M %M %n'
 . '%%p %p %n'
 . '%%P %P %n'
 . '%%r %r %n'
### %R is broken in Log::Log4perl version 1.16
### Invalid conversion in sprintf: "%R" at 
/usr/share/perl5/Log/Log4perl/Layout/PatternLayout.pm line 286.
#. '%%R %R %n'
 . '%%T %T %n'
 . '%%x %x %n',
});

print "### call DEBUG()\n";
DEBUG(   'main', __LINE__);
print "### call Foo::foo()\n";
Foo::foo('main', __LINE__);
print "### call Helper::help()\n";
Helper::help('main', __LINE__);



2011-01-23 14:30:20 dpchrist@p43400e ~/sandbox
$ perl log4perl-easy
### call DEBUG()
%c main
%C main
%d 2011/01/23 14:30:24
%F log4perl-easy
%H p43400e
%l main:: log4perl-easy (57)
%L 57
%m main57
%M main::
%p DEBUG
%P 5030
%r 41
%T Log::Log4perl::__ANON__('main', 57) called at log4perl-easy line 57
%x [undef]
### call Foo::foo()
%c Foo
%C Foo
%d 2011/01/23 14:30:24
%F log4perl-easy
%H p43400e
%l Foo::foo log4perl-easy (12)
%L 12
%m main59foo12
%M Foo::foo
%p DEBUG
%P 5030
%r 45
%T Foo::foo('main', 59) called at log4perl-easy line 59
%x [undef]
%c Helper
%C Foo
%d 2011/01/23 14:30:24
%F log4perl-easy
%H p43400e
%l Foo::foo log4perl-easy (13)
%L 13
%m main59foo13help26
%M Foo::foo
%p DEBUG
%P 5030
%r 45
%T Helper::help('main', 59, 'foo', 13) called at log4perl-easy line 13, 
Foo::foo('main', 59) called at log4perl-easy line 59
%x [undef]
### call Helper::help()
%c Helper
%C main
%d 2011/01/23 14:30:24
%F log4perl-easy
%H p43400e
%l main:: log4perl-easy (61)
%L 61
%m main61help26
%M main::
%p DEBUG
%P 5030
%r 46
%T Helper::help('main', 61) called at log4perl-easy line 61
%x [undef]



2011-01-23 14:22:11 dpchrist@p43400e ~/sandbox
$ cat log4perl-easy-category
#!/usr/bin/perl

$! = 1;

#
package Foo;
#
use strict;
use warnings;
use Log::Log4perl qw(:easy);
sub foo {
 DEBUG(   @_, 'foo', __LINE__);
 Helper::help(@_, 'foo', __LINE__);
}

###
package Helper;
###
use strict;
use warnings;
use Log::Log4perl qw(:easy);
sub help
{
 local $Log::Log4perl::caller_depth =
 $Log::Log4perl::caller_depth + 1;
 DEBUG(@_, 'help', __LINE__);
}

#
package main;
#
use strict;
use warnings;
use Log::Log4perl qw(:easy);

print "### no category\n";
Log::Log4perl->easy_init(
 {layout=>'%m category=%c %n'}
);
DEBUG(   'main', __LINE__);
Foo::foo('main', __LINE__);
Helper::help('main', __LINE__);

print "### category 'main'\n";
Log::Log4perl->easy_init(
 {layout=>'%m category=%c %n', category=>'main'}
);
DEBUG(   'main', __LINE__);
Foo::foo('main', __LINE__);
Helper::help('main', __LINE__);

print "### category 'Foo'\n";
Log::Log4perl->easy_init(
 {layout=>'%m category=%c %n', category=>'Foo'}
);
DEBUG(   'main', __LINE__);
Foo::foo('main', __LINE__);
Helper::help('main', __LINE__);



2011-01-23 14:22:51 dpchrist@p43400e ~/sandbox
$ perl log4perl-easy-category
### no category
main40 category=main
main41foo12 category=Foo
main41foo13help26 category=Helper
main42help26 categ

Re: [log4perl-devel] $Log::Log4perl::caller_depth, layout %c and %T, and category

2011-01-30 Thread David Christensen
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
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] $Log::Log4perl::caller_depth, layout %c and %T, and category

2011-01-30 Thread David Christensen
Mike Schilli wrote:
 > We get tons of spam on this list, so it's moderated.

That's what I thought.  I'll post to the list and BCC you.


> What you want to do instead is use the long form with get_logger():
> package Helper;
> use Log::Log4perl qw(get_logger);
> Log::Log4perl->wrapper_register(__PACKAGE__);
> sub help { get_logger()->debug(__FILE__, "-", __LINE__, ' ', @_) }

That solves both %c and 'category' -- thanks!  The 'category' filtering 
will be very useful.  :-)


I'm not certain if %T is doing the right thing (?).  You said there 
might be a bug.  Do you mean that the:

 ... Helper::help(...) called at ...

stances should be

 ... Log::Log4perl::__ANON__(...) called at ...

?  It's not a burning issue for me; I can use the output as is.


David



2011-01-30 19:53:41 dpchrist@p43400e ~/sandbox
$ nl log4perl-helper4.pl
  1 #!/usr/bin/perl
  2 package Helper;
  3 use Log::Log4perl qw(get_logger);
  4 Log::Log4perl->wrapper_register(__PACKAGE__);
  5 sub help { get_logger()->debug(@_, ' ', __FILE__, '-', __LINE__); }

  6 package Foo;
  7 sub foo { Helper::help(@_, ' ', __FILE__, '-', __LINE__); }

  8 package main;
  9 use Log::Log4perl qw(:easy);
 10 Log::Log4perl->easy_init({layout=>'%m %T %n'});
 11 DEBUG(   __FILE__, '-', __LINE__);
 12 print "\n";
 13 Helper::help(__FILE__, '-', __LINE__);
 14 print "\n";
 15 Foo::foo(__FILE__, '-', __LINE__);

2011-01-30 19:55:32 dpchrist@p43400e ~/sandbox
$ perl log4perl-helper4.pl
log4perl-helper4.pl-13 Log::Log4perl::__ANON__('log4perl-helper4.pl', 
'-', 13) called at log4perl-helper4.pl line 13

log4perl-helper4.pl-15 log4perl-helper4.pl-5 
Helper::help('log4perl-helper4.pl', '-', 15) called at 
log4perl-helper4.pl line 15

log4perl-helper4.pl-17 log4perl-helper4.pl-8 log4perl-helper4.pl-5 
Helper::help('log4perl-helper4.pl', '-', 17, ' ', 'log4perl-helper4.pl', 
'-', 8) called at log4perl-helper4.pl line 8, 
Foo::foo('log4perl-helper4.pl', '-', 17) called at log4perl-helper4.pl 
line 17

2011-01-30 19:55:35 dpchrist@p43400e ~/sandbox
$ cat /etc/debian_version
5.0.8

2011-01-30 19:55:44 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 19:55:46 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
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] how to enable/disable appender in config file based on %ENV variable?

2011-09-19 Thread David Christensen
log4perl-devel:

I'm working on a web application and would like to log TRACE priority 
messages related to hits from my development machine (IP address 
192.168.0.34).  This is the relevant portion of my configuration file:

 2011-09-19 12:31:51 dpchrist@p43400e ~
 $ grep TraceApp perl-src/50-Dpchrist-CMS/demo/conf/log4perl.conf
 log4perl.logger = TRACE, InfoApp, TraceApp
 log4perl.appender.TraceApp = Log::Log4perl::Appender::File
 log4perl.appender.TraceApp.filename = sub { $ENV{REMOTE_ADDR} eq 
'192.168.0.34' ? $Mysite::CONF{-log_dir} . '/trace.log' : '/dev/null' }
 log4perl.appender.TraceApp.mode = append
 log4perl.appender.TraceApp.layout = PatternLayout
 log4perl.appender.TraceApp.layout.ConversionPattern = 
%d{MMdd-HHmmss.SSS} %p %M (%F{1} %L) %m{chomp}%n
 log4perl.appender.TraceApp.Threshold = TRACE


I would prefer to enable/ disable TraceApp based on $ENV{REMOTE_ADDR} 
rather than doing all the work and throwing non-192.168.0.34 hits down 
/dev/null, but I couldn't figure out how to implement this idea.


Is there a better way?


TIA,

David

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] how to enable/disable appender in config file based on %ENV variable?

2011-09-20 Thread David Christensen
On 09/19/2011 11:37 PM, Kevin Goess wrote:
> See 'perldoc Log::Log4perl::Filter'

On 09/20/2011 12:20 AM, Mike Schilli wrote:
 > The Log::Log4perl::Filter manpage explains their use in detail.

That solved it.  Thanks!  :-)

 2011-09-20 12:38:06 dpchrist@p43400e ~
 $ grep Trace perl-src/50-Dpchrist-CMS/demo/conf/log4perl.conf
 log4perl.logger = TRACE, InfoApp, TraceApp
 log4perl.filter.TraceFilter = sub {$ENV{REMOTE_ADDR} eq 
$Mysite::CONF{-trace_ip}}
 log4perl.appender.TraceApp = Log::Log4perl::Appender::File
 log4perl.appender.TraceApp.filename = sub { 
File::Spec::Functions::catfile($Mysite::CONF{-log_dir}, 'trace.log') }
 log4perl.appender.TraceApp.Filter = TraceFilter
 log4perl.appender.TraceApp.mode = append
 log4perl.appender.TraceApp.layout = PatternLayout
 log4perl.appender.TraceApp.layout.ConversionPattern = 
%d{MMdd-HHmmss.SSS} %p %M (%F{1} %L) %m{chomp}%n
 log4perl.appender.TraceApp.Threshold = TRACE


David

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] Log::Log4perl best practices

2011-09-25 Thread David Christensen
log4perl:

I started with Log4perl a few months ago and wrote some modules that use 
Log4perl in easy mode with no get_logger() categories.  I'm now working 
on more modules and an application that uses Log4perl configuration 
files and get_logger() categories.  I'd like to upgrade everything to 
whatever is consider best (or better) practices.


Any suggestions?


TIA,

David

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Log::Log4perl best practices

2011-09-28 Thread David Christensen
On 09/26/2011 10:14 AM, Mike Schilli wrote:
> Actually, :easy mode macros and get_logger() are identical in function,
> the difference is just typing convenience.
>
> I personally use :easy macros like DEBUG and INFO in conjunction with
> log4perl configuration files, unless for really simple scripts for which
> easy_init() is more appropriate.

Ok.  I've upgraded my wrapper functions to use caller() when calling 
get_logger().


Thanks!


David


--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Log::Log4perl best practices

2011-09-29 Thread David Christensen
On 09/28/2011 11:04 PM, Mike Schilli wrote:
> If you want to bump up the caller level, you should be using
> wrapper_register() or $Log::Log4perl::caller_depth as explained here:
> http://search.cpan.org/dist/Log-Log4perl/lib/Log/Log4perl.pm#Using_Log::Log4perl_with_wrapper_functions_and_classes

Yes.


On 09/28/2011 11:04 PM, Mike Schilli wrote:
 > On Wed, 28 Sep 2011, David Christensen wrote:
 >> Ok. I've upgraded my wrapper functions to use caller() when calling
 >> get_logger().
 > That doesn't sound right.

My wrappers now call, in effect:

 get_logger('caller.package.subroutine.line')

This should give me more opportunities to use categories.


David


--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] OT: friendly Java mailing list/ forum?

2013-05-23 Thread David Christensen
log4perl-devel:

I'm attempting to learn Java using jdk1.7.0_17 on Debian 6.0.7 and have 
found the Oracle Discussion Forums to be less than helpful:

 https://forums.oracle.com/forums/category.jspa?categoryID=285

Since log4perl is based on a Java concept, can anybody recommend a 
friendly mailing list or forum for experienced programmers learning Java 
using command-line tools, not an IDE?

TIA,

David

--
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] logwarn() not outputting warnings when logger not enabled

2013-11-04 Thread David Christensen
log4perl-devel:

I am working on a module that incorporates stealth logging.  I've used 
logwarn() in place of warn() throughout.

When I enable a logger in a script that use's the module, I see warning 
messages both on the terminal and in the log destination.

But, when there is no logger enabled, I don't see any warning messages 
on the terminal.  I was expecting logwarn() would always output the 
warning message to the terminal, and additionally output the warning 
message to the log destination if logging is enabled.  Apparently, not.

As an aside, logdie() appears to work as expected.

I see that Log::Log4perl is now version 1.42 on CPAN.  I'm on Debian 
Stable (Wheezy), which has version 1.29.  I'd  rather not upgrade via 
'cpan', as I've found that circumventing Apt and the Debian release 
process leads to problems.

I don't see liblog-log4perl-perl on Debian Backports.

Any suggestions?

TIA,

David



2013-11-04 23:08:03 dpchrist@p43200 ~/sandbox/perl
$ cat Log-Log4perl-logwarn.pl
#!/usr/bin/perl
use strict;
use warnings;
use Log::Log4perl   qw(:easy);
warn "first warning";
my $logger = Log::Log4perl->get_logger();
$logger->logwarn("second warning");
Log::Log4perl->easy_init($WARN);
warn "third warning";
$logger->logwarn("fourth warning");

2013-11-04 23:08:08 dpchrist@p43200 ~/sandbox/perl
$ perl Log-Log4perl-logwarn.pl
first warning at Log-Log4perl-logwarn.pl line 5.
third warning at Log-Log4perl-logwarn.pl line 9.
2013/11/04 23:08:12 fourth warning
fourth warning at Log-Log4perl-logwarn.pl line 10

2013-11-04 23:08:12 dpchrist@p43200 ~/sandbox/perl
$ cat Log-Log4perl-logdie.pl
#!/usr/bin/perl
use strict;
use warnings;
use Log::Log4perl   qw(:easy);
my $logger = Log::Log4perl->get_logger();
$logger->logdie("bye");

2013-11-04 23:08:18 dpchrist@p43200 ~/sandbox/perl
$ perl Log-Log4perl-logdie.pl
bye at Log-Log4perl-logdie.pl line 6

2013-11-04 23:08:23 dpchrist@p43200 ~/sandbox/perl
$ cat Log-Log4perl-logdie2.pl
#!/usr/bin/perl
use strict;
use warnings;
use Log::Log4perl   qw(:easy);
Log::Log4perl->easy_init($WARN);
my $logger = Log::Log4perl->get_logger();
$logger->logdie("bye");

2013-11-04 23:08:31 dpchrist@p43200 ~/sandbox/perl
$ perl Log-Log4perl-logdie2.pl
2013/11/04 23:08:34 bye
bye at Log-Log4perl-logdie2.pl line 7

2013-11-04 23:08:34 dpchrist@p43200 ~/sandbox/perl
$ perl -MLog::Log4perl -e 'print $Log::Log4perl::VERSION, "\n"'
1.29

2013-11-04 23:08:45 dpchrist@p43200 ~/sandbox/perl
$ perl --version

This is perl 5, version 14, subversion 2 (v5.14.2) built for 
i486-linux-gnu-thread-multi-64int
(with 88 registered patches, see perl -V for more detail)

Copyright 1987-2011, 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.


2013-11-04 23:08:55 dpchrist@p43200 ~/sandbox/perl
$ cat /etc/debian_version
7.2

--
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] logwarn() not outputting warnings when logger not enabled

2013-11-05 Thread David Christensen
On 11/04/2013 11:18 PM, David Christensen wrote:
> I was expecting logwarn() would always output the
> warning message to the terminal, and additionally output the warning
> message to the log destination if logging is enabled.

I found a work-around -- write a wrapper that calls warn() and 
$logger->warn() instead.


HTH,

David



2013-11-05 10:01:04 dpchrist@p43200 ~/sandbox/perl
$ cat Log-Log4perl-warn.pl
#!/usr/bin/perl
use strict;
use warnings;
use Log::Log4perl   qw(:easy);
sub mylogwarn {
 my $logger = Log::Log4perl->get_logger();
 warn @_;
 $logger->warn(@_);
}
mylogwarn "first warning";
Log::Log4perl->easy_init($WARN);
mylogwarn "second warning";

2013-11-05 10:01:10 dpchrist@p43200 ~/sandbox/perl
$ perl Log-Log4perl-warn.pl
first warning at Log-Log4perl-warn.pl line 7.
second warning at Log-Log4perl-warn.pl line 7.
2013/11/05 10:01:13 second warning



--
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] logwarn() not outputting warnings when logger not enabled

2013-11-05 Thread David Christensen
On 11/05/2013 06:17 PM, Mike Schilli wrote:

Thanks for the reply, and thanks for Log::Log4perl.  :-)


> This was fixed in Log4perl 1.35:

I suspected as much.


> I wouldn't do it in the main root to avoid stepping on the package
> manager's files, but if you maintain your own local directory via
> local::lib that should work just fine.

I use local::lib for my code, but try to use the distribution package 
manager for CPAN modules.  If/when I must have a CPAN module that isn't 
packaged, I'll put it in local::lib.


> Ideally, I wouldn't use the
> system perl for applications in the first place, but install a separate
> one via perlbrew et al.
...
> Later versions of Debian seem to have more up-to-date versions of
> Log4perl:

I'm working on modules/ scripts to automate system configuration/ 
administration of Debian 7 machines.  So, I'm trying to write Perl code 
that works with Debian 7 OOTB as much as possible.


I'll go with my wrapper work-around for now.


David



--
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel