Re: [log4perl-devel] log4perl buffering with semi persistent scripts

2011-12-07 Thread Danny Dev
You didn't mention the email appender that you are using, specific
solutions would require looking into the appender's documentation and
figure out if it provides a method to flush buffered/pending messages.

If that's available, then I'd recommend encapsulating request handling
into a function scope and run a flush() at the end.

thanks for the reply, 


I'm using Log::Dispatch::Email::MailSend which doesn't implement its own flush 
method. I took at look at all of the available Email appenders and none of them 
do, it's only in the base class but actually the base class method appears to 
do the job.
I'm not clear on how I call that directly however since I can't  call it 
against the object returned by get_logger and I have to pass it the correct 
object if  I call it directly

Log::Dispatch::Email::flush(???)

cheers


--
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] log4perl buffering with semi persistent scripts

2011-12-07 Thread Danny Dev
Ahh may have found it, it looks like 


http://log4perl.sourceforge.net/d/Log/Log4perl/FAQ.html#92664

using appender_by_name lets me call flush on it

cheers



- Original Message -
From: Danny Dev dannydev...@yahoo.com
To: Mike Schilli m...@perlmeister.com
Cc: log4perl-devel@lists.sourceforge.net 
log4perl-devel@lists.sourceforge.net
Sent: Wednesday, December 7, 2011 9:19 AM
Subject: Re: [log4perl-devel] log4perl buffering with semi persistent  scripts

You didn't mention the email appender that you are using, specific
solutions would require looking into the appender's documentation and
figure out if it provides a method to flush buffered/pending messages.

If that's available, then I'd recommend encapsulating request handling
into a function scope and run a flush() at the end.

thanks for the reply, 


I'm using Log::Dispatch::Email::MailSend which doesn't implement its own flush 
method. I took at look at all of the available Email appenders and none of them 
do, it's only in the base class but actually the base class method appears to 
do the job.
I'm not clear on how I call that directly however since I can't  call it 
against the object returned by get_logger and I have to pass it the correct 
object if  I call it directly

Log::Dispatch::Email::flush(???)

cheers

--
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] log4perl buffering with semi persistent scripts

2011-12-06 Thread Danny Dev
I'm using log4perl in FCGI scripts that are semi-persistent, they go up and 
down depending on load.

I have an appender that sends email and I'd like it to be buffered. However if 
I set it to buffered the emails are never sent, except sometimes when the 
process is killed.  If  I disable buffering it works fine but the messages are 
split up into too many individual emails.

I think perhaps what I need is to enable buffering at the start of each 
request, and disable it at the end of the request, is there some way to do this 
or does someone have another solution?

I took a look at some of the information for mod_perl but it doesn't quite seem 
to pertain, and in my case the FCGIs are only persistent for a number of 
requests then eventually exit.

cheers for any advice
Danny
--
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] Log4perl 1.31 released

2010-10-27 Thread Mike Schilli
Hi Log4perl enthusiasts,

Log4perl 1.31 just has been released to CPAN. It fixes only one
annoying test problem on Windows:

1.31 (2010/10/27)
   * (ms) Fixed the number of skipped tests for Windows for previous
 fix of [RT 60665].

Just didn't want to sit on it any longer, enjoy!

-- Mike

Mike Schilli
m...@perlmeister.com

--
Nokia and ATT present the 2010 Calling All Innovators-North America contest
Create new apps  games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] log4perl Data::Dumper and renaming $VAR1

2010-04-09 Thread Mike Schilli
On Fri, 9 Apr 2010, Josh803316 wrote:

 $logger-trace( {filter = \Data::Dumper::Dumper, value = $name},
 undef, $TRACE, undef, undef); So my question is, how can I log the
 value so it looks like $name instead of $VAR1 in the saved log?

You can pass a reference to a subroutine to Log4perl's logging methods:

  $logger-trace( sub { Data::Dumper-Dump([$name], ['name']) } );

would do the trick while retaining the time-saving late evaluation.

-- Mike

Mike Schilli
m...@perlmeister.com

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] log4perl Data::Dumper and renaming $VAR1

2010-04-09 Thread Mike Schilli
On Fri, 9 Apr 2010, Josh803316 wrote:

 wn edificationwhat is the real difference between the filter
 method and the sub method or are they basically the same?

They're the same, just different notations.

-- Mike

Mike Schilli
m...@perlmeister.com

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] Log4perl 1.27 Released

2010-02-07 Thread Mike Schilli
Hi Log4perl enthusiasts,

Log::Log4perl 1.27 has just been released to CPAN. The following changes
went into this release:

1.27 (2010/02/07)
*(ms) ***WARNING: This might break backward compatibility
  with some wrapper classes.
  [RT 52913] Fixed category fetching in
  wrapper classes (reported by Martin Evans). Wrapper classes
  now need to call Log::Log4perl-wrapper_register to adapt
  get_logger() category fetching. Detailed docs under
  Using Log::Log4perl with wrapper functions and classes
*(ms) Made meta tag compatible with MakeMaker versions  6.50
 (ms) [RT 52083] Fixed manifest glitch from 1.26 (reported by
  Lars Thegler).
*(ms) Added note to FAQ on 'no init happened' warnings for API
  initializations, as suggested by Malcolm Nooning.
*(ms) Applied patch by Christopher Mckay which sets
  Log4perl::Logger::INITIALIZED only if it's fully initialized.
*(ms) Emmanuel Rodriguez suggested changing TestBuffer's reset()
  method to leave the logger population alone. Added clear()
  to accomodate the need for a single buffer reset.
*(ms) Xavier Caron added %p{1} to allow abbreviated priority
  strings in the pattern layout.
*(ms) Redid composite appenders to address problems with incorrect
  caller() data. L4p now supports a $cache parameter to be
  passed to the log() function, which stores the completely
  rendered message and can be passed to log_cached() later on.

Enjoy!

-- Mike

Mike Schilli
m...@perlmeister.com

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Log4perl best practices for high traffic sites

2010-01-27 Thread Mike Schilli
On Wed, 20 Jan 2010, Trevor Little wrote:

   I'm adding logging to a high-traffic mod_perl website and am worried
   about the performance penalties of writing stuff to disc on every
   request.

It depends on your traffic numbers. I've found that a file appender
works quite well up to 1000 reqs/sec because the OS typically caches
disc access quite efficiently. Your mileage might vary, so prudent load
testing is of the essence.

-- Mike

Mike Schilli
m...@perlmeister.com

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] Log4perl best practices for high traffic sites

2010-01-25 Thread Trevor Little
Hi,
   I'm adding logging to a high-traffic mod_perl website and am worried  
about the performance penalties of writing stuff to disc on every request.  
In production, we'd probably only be logging a few lines per request. I'm  
wondering what the common usage of log4perl is like in these situations.  
I've seen suggestions for piping messages to a message bus with something  
like Log::Log4perl::Appender::Spread, but I'd love to hear what the  
experiences of people on this list have been when deploying log4perl on  
high traffic sites. What's worked, what hasn't? Is anyone logging directly  
to a database?

Thanks in advance for your insight,

Trevor

--
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] Log4perl 1.26 released

2009-11-22 Thread Mike Schilli

Hi Log4perl enthusiasts,

Log4perl 1.26 has just been released on github:

http://github.com/mschilli/log4perl/tarball/rel_126

Changes in this release:

1.26 (2009/11/22)
*   (ms) [RT 50495] Perl code in the config file is now evaluated/
compiled after the configuration parser has done its work,
opening up Perl subroutines to all configuration parsers, not
just PropertyConfigurator. Configuration subs for cspecs,
filter, warp_message and appender triggers are sheltered. The
previous, flawed implementation surfaced while using a
'trigger' category, reported by Olivier Bilodeau.
*   (ms) [RT 50090] Added non-portable linebreaks to PatternLayout
(requested by Zdeněk Juran).
*   (ms) [RT 50094] Docfix for PatternLayout in main manpage
(spotted by Peter Rabbitson).
*   (ms) [RT 28679] Added exists() to Threshold keyword
uppercase check.
*   (ms) Took out Class::Prototyped testcase after it got all
weird and introduced backward-incompatible changes.

If all goes well, it'll hit CPAN in a couple of days.

-- Mike

Mike Schilli
m...@perlmeister.com--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] Log4perl 1.25 released

2009-09-27 Thread Mike Schilli
Hi Log4perl enthusiasts,

release 1.25 just went out to log4perl.com, here's the changes:

1.25 (2009/09/27)
 *   (ms) Appender::File is now closing (or sysclosing) the file
  on file_close() instead of just undef'ing the handle.
 *   (ms) Added l4p-tmpl helper script to help whipping up a new
  log4perl configuration file.
 *   (ms) Fixed uninitialized warning on XML configuration files,
  reported by jbkilian on the sourceforge mailing list.
 *   (ms) Applied patch [RT 43426] by AFF a...@cpan.org to have
  appender_thresholds_adjust return number of appenders changed.
 *   (ms) [RT 34400] New :nostrict target which allows redefining a
  category within a Log4perl configuration file without error
  or even a warning.
 *   (ms) [RT 34401] Applied patch by Jae Gangemi, who fixed
  code references in @INC on Win32 systems.
 *   (ms) [RT 32259] Patternlayout now supports %R, which returns the
  number of milliseconds elapsed from last logging event to
  the current logging event (thanks to Emmanuel Rodriguez for
  the patch).
 *   (ms) [RT 30899] Color configuration and attribute support
  added to ScreenColoredLevels appender by Jason Kohles.
 *   (ms) [RT 28987] If UNIVERSAL is available, appender existence is
  now verified by checking can() on the appender's new()
  method (applied modified patch by Gabriel Berriz).

If all goes well, it'll hit CPAN in a couple of days.

Enjoy!

-- Mike

Mike Schilli
m...@perlmeister.com

--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] log4perl License?

2009-09-11 Thread Terry Kummell
Do we need to license log4perl in order to use it in our product?

 

Regards,

Terry

 

--

Terry Kummell

Aldon Computer Group

6001 Shellmound St.  Suite 600

Emeryville, CA 94608

(510) 285-8527

 

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] log4perl License?

2009-09-11 Thread Mike Schilli
On Fri, 11 Sep 2009, Terry Kummell wrote:

 Do we need to license log4perl in order to use it in our product?

Hi Terry,

Log4perl is provided under the same license as perl itself:

 http://dev.perl.org/licenses/

Hope that helps!

-- Mike

Mike Schilli
m...@perlmeister.com

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Log4perl

2009-07-07 Thread Mike Schilli
On Mon, 6 Jul 2009, Oladipo, Segun wrote:

 Need to install Log4perl but stuck behind a firewall.  Obtained
 information that it is possible to download the zipped file to a local
 repository and install using ppm.

The PPM is for Activestate Perl only, and it wasn't updated with the
last release by accident. I've just run the script that pushed the
current (1.23) release to
http://log4perl.sourceforge.net/ppm/Log-Log4perl.ppd, please try again!

Regarding your Firewall, if you have http access to the outside world
(as you seem to have if you can download a zipped file) you should as
well be able to use the normal CPAN installer (which can be configured
to use http).

-- Mike

Mike Schilli
m...@perlmeister.com

--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] Log4perl

2009-07-06 Thread Oladipo, Segun
Hello,

Need to install Log4perl but stuck behind a firewall.
Obtained information that it is possible to download the zipped file to a local 
repository and install using ppm.
The question is I can't seem to find Log-Log4perl.ppd anywhere as the following 
link seems to be inactive.

http://log4perl.sourceforge.net/ppm/Log-Log4perl.ppd

Please advise.

Thanks for help in advance.

Segun Oladipo | Snr Application Developer - IMDS I CIBC Global Operations  
INTRIA | T:905-502-4926 | segun.olad...@cibc.commailto:segun.olad...@cibc.com



--
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have 
the opportunity to enter the BlackBerry Developer Challenge. See full prize 
details at: http://p.sf.net/sfu/blackberry___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Log4perl and catching unhandle exceptions but not using 'easy' mode

2009-05-27 Thread Richard Burton
Hi Mike

Firstly thanks for the help your help so far..

I think I am almost seeing the light, my only question now is actually
outputting the log text, below is my test script, could you outline what
I should be putting for the line :-

get_logger()-info(@_) in the PRINT method of package Trapper;

Currently the whole script gets in to a recursive mess, the file
logging.conf contains a simple root logger which outputs to the screen,
I have attached it but I suspect it is not of any use.



#
#!/usr/bin/perl -w
use strict;

use Log::Log4perl qw( get_logger :levels );
use Log::Log4perl::Level;

main();

sub main {

Log::Log4perl-init_once('logging.conf');

my $log = Log::Log4perl-get_logger('');
tie *STDERR, Trapper;
$log-info(This is an informational);
$log-error(This is an error);
IgnorantModule::some_method();

}



package IgnorantModule;


sub some_method {
print STDERR Parbleu! An error!\n;
}

1;



package Trapper;


use Log::Log4perl qw( get_logger :levels );

sub TIEHANDLE {
my $class = shift;
bless [], $class;
}

sub PRINT {
my $self = shift;

$Log::Log4perl::caller_depth++;
get_logger()-info(@_);
$Log::Log4perl::caller_depth--;
}

1; 
#



Thanks

Richard


 -Original Message-
 From: Mike Schilli [mailto:m...@perlmeister.com] 
 Sent: 20 May 2009 22:25
 To: Richard Burton
 Cc: log4perl-devel@lists.sourceforge.net
 Subject: Re: [log4perl-devel] Log4perl and catching unhandle 
 exceptions but not using 'easy' mode
 
 On Wed, 20 May 2009, Richard Burton wrote:
 
  I can catch this using stealth as loggers outlined in
  
 http://search.cpan.org/~mschilli/Log-Log4perl/lib/Log/Log4perl
 /FAQ.pm#So
  
 me_module_prints_messages_to_STDERR._How_can_I_funnel_them_to_
 Log::Log4p
  erl?
 
  but the example assumes you are using the easy 
 configuration method.
 
 Actually, this will work unmodified if you're using a 
 configuration file
 instead.
 
 You're probably talking about the DEBUG(...) macro used in the code
 example, which comes with :easy, but this is really unrelated to
 easy_init() and can be used with init($conf_file) as well.
 If you don't want the stealth loggers, get a logger and send 
 your debug
 message via
 
  use Log::Log4perl qw(get_logger);
 
  get_logger()-debug(my debug message);
 
 instead.
 
  The question I have is can I do a similar thing but use an external
  configuration file for log4perl? I have tried but failed so would
  appreciate any guidance?
 
 This should work, what was the problem/error message you encountered?
 
 -- Mike
 
 Mike Schilli
 m...@perlmeister.com
 


logging.conf
Description: logging.conf
--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA,  Big Spaceship. http://p.sf.net/sfu/creativitycat-com ___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Log4perl and catching unhandle exceptions but not using 'easy' mode

2009-05-21 Thread Mike Schilli
On Wed, 20 May 2009, Robert Jacobson wrote:

 Here's what I did: 1.  Make a file trapper.pl.  It's basically the
 same as the example, except the Log4perl init, which uses a config
 file (in this case, with a SIGHUP to re-read it):

Looks ok at first glance, doesn't it produce the expected output?

Please post the complete (runnable) code to make it easier to diagnose
the problem.

-- Mike

Mike Schilli
m...@perlmeister.com


   
   package Trapper;
   

   use Log::Log4perl qw(get_logger :levels);

   Log::Log4perl-init_and_watch(../log4perl.conf,'HUP');
   my $logger = get_logger(program.category);


   sub TIEHANDLE {
   ... [etc]

 2. In my perl program:
   require trapper.pl;
   tie (*STDERR, 'Trapper');


 HTH,
 Rob




 --
 Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
 is a gathering of tech-side developers  brand creativity professionals. Meet
 the minds behind Google Creative Lab, Visual Complexity, Processing, 
 iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
 Group, R/GA,  Big Spaceship. http://www.creativitycat.com
 ___
 log4perl-devel mailing list
 log4perl-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/log4perl-devel


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Log4perl and catching unhandle exceptions but not using 'easy' mode

2009-05-21 Thread Richard Burton
Hi Mike

All I am trying to do is to write unhandled exceptions to file, e.g. I
am using a package off CPAN that explodes in a horrible way but as the
exception is internal to the package I may not have the relevant error
checking in place to catch the error? It is more of a general question
so that I can build it in to my code; I don't have a specific example?

Does that help?

Richard 

 -Original Message-
 From: Mike Schilli [mailto:m...@perlmeister.com] 
 Sent: 20 May 2009 22:25
 To: Richard Burton
 Cc: log4perl-devel@lists.sourceforge.net
 Subject: Re: [log4perl-devel] Log4perl and catching unhandle 
 exceptions but not using 'easy' mode
 
 On Wed, 20 May 2009, Richard Burton wrote:
 
  I can catch this using stealth as loggers outlined in
  
 http://search.cpan.org/~mschilli/Log-Log4perl/lib/Log/Log4perl
 /FAQ.pm#So
  
 me_module_prints_messages_to_STDERR._How_can_I_funnel_them_to_
 Log::Log4p
  erl?
 
  but the example assumes you are using the easy 
 configuration method.
 
 Actually, this will work unmodified if you're using a 
 configuration file
 instead.
 
 You're probably talking about the DEBUG(...) macro used in the code
 example, which comes with :easy, but this is really unrelated to
 easy_init() and can be used with init($conf_file) as well.
 If you don't want the stealth loggers, get a logger and send 
 your debug
 message via
 
  use Log::Log4perl qw(get_logger);
 
  get_logger()-debug(my debug message);
 
 instead.
 
  The question I have is can I do a similar thing but use an external
  configuration file for log4perl? I have tried but failed so would
  appreciate any guidance?
 
 This should work, what was the problem/error message you encountered?
 
 -- Mike
 
 Mike Schilli
 m...@perlmeister.com
 

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Log4perl and catching unhandle exceptions but not using 'easy' mode

2009-05-21 Thread Mike Schilli
On Thu, 21 May 2009, Richard Burton wrote:

 It is more of a general question so that I can build it in to my code;
 I don't have a specific example?

Maybe I misunderstood, but you said I have tried but failed, and from
what I saw, you're doing everything correctly.

-- Mike

Mike Schilli
m...@perlmeister.com


 Does that help?

 Richard

 -Original Message-
 From: Mike Schilli [mailto:m...@perlmeister.com]
 Sent: 20 May 2009 22:25
 To: Richard Burton
 Cc: log4perl-devel@lists.sourceforge.net
 Subject: Re: [log4perl-devel] Log4perl and catching unhandle
 exceptions but not using 'easy' mode

 On Wed, 20 May 2009, Richard Burton wrote:

 I can catch this using stealth as loggers outlined in

 http://search.cpan.org/~mschilli/Log-Log4perl/lib/Log/Log4perl
 /FAQ.pm#So

 me_module_prints_messages_to_STDERR._How_can_I_funnel_them_to_
 Log::Log4p
 erl?

 but the example assumes you are using the easy
 configuration method.

 Actually, this will work unmodified if you're using a
 configuration file
 instead.

 You're probably talking about the DEBUG(...) macro used in the code
 example, which comes with :easy, but this is really unrelated to
 easy_init() and can be used with init($conf_file) as well.
 If you don't want the stealth loggers, get a logger and send
 your debug
 message via

  use Log::Log4perl qw(get_logger);

  get_logger()-debug(my debug message);

 instead.

 The question I have is can I do a similar thing but use an external
 configuration file for log4perl? I have tried but failed so would
 appreciate any guidance?

 This should work, what was the problem/error message you encountered?

 -- Mike

 Mike Schilli
 m...@perlmeister.com


 --
 Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
 is a gathering of tech-side developers  brand creativity professionals. Meet
 the minds behind Google Creative Lab, Visual Complexity, Processing, 
 iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
 Group, R/GA,  Big Spaceship. http://www.creativitycat.com
 ___
 log4perl-devel mailing list
 log4perl-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/log4perl-devel


--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Log4perl and catching unhandle exceptions but not using 'easy' mode

2009-05-20 Thread Mike Schilli
On Wed, 20 May 2009, Richard Burton wrote:

 I can catch this using stealth as loggers outlined in
 http://search.cpan.org/~mschilli/Log-Log4perl/lib/Log/Log4perl/FAQ.pm#So
 me_module_prints_messages_to_STDERR._How_can_I_funnel_them_to_Log::Log4p
 erl?

 but the example assumes you are using the easy configuration method.

Actually, this will work unmodified if you're using a configuration file
instead.

You're probably talking about the DEBUG(...) macro used in the code
example, which comes with :easy, but this is really unrelated to
easy_init() and can be used with init($conf_file) as well.
If you don't want the stealth loggers, get a logger and send your debug
message via

 use Log::Log4perl qw(get_logger);

 get_logger()-debug(my debug message);

instead.

 The question I have is can I do a similar thing but use an external
 configuration file for log4perl? I have tried but failed so would
 appreciate any guidance?

This should work, what was the problem/error message you encountered?

-- Mike

Mike Schilli
m...@perlmeister.com

--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Log4perl and catching unhandle exceptions but not using 'easy' mode

2009-05-20 Thread Robert Jacobson
Richard Burton richard-at-atomwide.com |log4perl_sourceforge| wrote:
 Hi all
 
 I am trying to capture unhandled exceptions that are sent to STDERR,
 e.g. for example the following could would give such an error
[snip]
 
 I can catch this using stealth as loggers outlined in
 
 http://search.cpan.org/~mschilli/Log-Log4perl/lib/Log/Log4perl/FAQ.pm#So
 me_module_prints_messages_to_STDERR._How_can_I_funnel_them_to_Log::Log4p
 erl?
 
 but the example assumes you are using the easy configuration method.
 
 The question I have is can I do a similar thing but use an external
 configuration file for log4perl? I have tried but failed so would
 appreciate any guidance?


Here's what I did:
1.  Make a file trapper.pl.  It's basically the same as the example,
except the Log4perl init, which uses a config file (in this case, with a
 SIGHUP to re-read it):


package Trapper;


use Log::Log4perl qw(get_logger :levels);

Log::Log4perl-init_and_watch(../log4perl.conf,'HUP');
my $logger = get_logger(program.category);


sub TIEHANDLE {
... [etc]

2. In my perl program:
require trapper.pl;
tie (*STDERR, 'Trapper');


HTH,
Rob




--
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers  brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing,  
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA,  Big Spaceship. http://www.creativitycat.com 
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


[log4perl-devel] Log4perl - Multiple files and different log levels

2009-01-26 Thread Manoj Wanzare

Dear All,
 I am a new user of log4perl and to this mailing list. I am working on a perl 
project - want to incorporate Log4perl as main logging framework. The 
requirement is as below:
 
  1) Wrapper over Log4perl
  2) System-wide Logging to File  Screen in INFO mode
  3) DEBUG mode should have an option of either writing to Screen or 
debuglog file or both
  4) Option to replicate debug log messages in system-wide logging if debug 
log is turned of.
 
  Creating a package and using a log4 conf file with rootLogger in INFO mode 
and Logfile and Screen as appenders take care of requirement 12 however option 
third and fourth is tricky to incorporate. I have tried Filter match etc but 
cannot seem to get my head around effectively incorporating requirement 3  4. 
 
   Any suggestions would be greatly appreciate. Thanks in advance.
 
Cheers
 
MSW
 
 
 
  
_
Plug in to the MSN Tech channel for a full update on the latest gizmos that 
made an impact.
http://computing.in.msn.com/--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Log4perl - Multiple files and different log levels

2009-01-26 Thread Mike Schilli
On Mon, 26 Jan 2009, Manoj Wanzare wrote:

  3) DEBUG mode should have an option of either writing to Screen
 or debuglog file or both

I presume that 'debug mode' is a mode your application is in, so it
would be available in a variable of the program? If so, you can attach
a filter to each appender and have it check if the appender is supposed
to fire or not:

  log4perl.category = DEBUG, Logfile, Screen

  log4perl.appender.Logfile = Log::Log4perl::Appender::File
  log4perl.appender.Logfile.filename = test.log
  log4perl.appender.Logfile.layout = \
Log::Log4perl::Layout::SimpleLayout
  log4perl.appender.Logfile.Filter = LogFileFilter

  log4perl.appender.Screen = Log::Log4perl::Appender::Screen
  log4perl.appender.Screen.layout = \
Log::Log4perl::Layout::SimpleLayout
  log4perl.appender.Screen.Filter = ScreenFilter

  log4perl.filter.ScreenFilter  = \
   sub { my %p = @_; $p{log4p_level} eq INFO or $main::debug_mode_to_screen }
  log4perl.filter.LogFileFilter = \
   sub { my %p = @_; $p{log4p_level} eq INFO or $main::debug_mode_to_file }

The Log::Log4perl::Filter docs show more details. You probably want to
write a custom Log::Log4perl::Filter to keep the filter logic separate
from the Log4perl configuration file. In the config above, if you set

 our $debug_mode_to_screen = 0;
 our $debug_mode_to_file   = 0;

in the main program, nothing will happen with debug messages (but still 
with info messages).

  4) Option to replicate debug log messages in system-wide
 logging if debug log is turned of.

Hmm, I need some clarification on this one -- what exactly do you want
to replicate?

-- Mike

Mike Schilli
m...@perlmeister.com

 I am a new user of log4perl and to this mailing list. I am working
 on a perl project - want to incorporate Log4perl as main logging
 framework. The requirement is as below:

  1) Wrapper over Log4perl
  2) System-wide Logging to File  Screen in INFO mode
  3) DEBUG mode should have an option of either writing to Screen
 or debuglog file or both
  4) Option to replicate debug log messages in system-wide
 logging if debug log is turned of.

  Creating a package and using a log4 conf file with rootLogger in
  INFO mode and Logfile and Screen as appenders take care of
  requirement 12 however option third and fourth is tricky to
  incorporate. I have tried Filter match etc but cannot seem to get
  my head around effectively incorporating requirement 3  4.


--
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] log4perl appenders with warp_message=0

2008-05-15 Thread Mike Schilli
On Tue, 13 May 2008, Erskine, Thomas (IT) wrote:

 While warp_message is indeed an appender setting, if you have two
 appenders, one with warp_message=0 and one without, then you'll get
 the mess I got: the one with will work fine and will have access to
 extra args separately, but the one without will mash the args into
 a single message.

 Perhaps I ought to have said that, while it's possible to have appenders
 with warp_message=0 and those without in the same setup, it's not
 _useful_ as the result will be a mess.

It's a dilemma: We're hiding probes in the code that should work
for all appenders, and yet some appenders interpret them differently.
Note that the Log4perl configuration is supposed to be independent of
the code. Any person, even those unfamiliar with your code, should be
able to define a Log4perl config file from scratch to run it with.
I'm admitting that this is a stretch (and what L4p does deviates
from the strict Log4j standard) but we've found it useful for database
appenders, for example. I'll be the first to admit, though, that this
isn't a 100% clean solution.

I guess you could find arguments either way, but I feel that mashing
arguments as a default is reasonable and provides predictable results.

 On a completely different topic, while making a Null appender (which
 discards everything), I noticed that it doesn't seem possible to make
 the initializer shut up about it not having a layout.  Even though
 I added in code to the new to cause it to inflict the NoopLayout to
 itself.  It just seemed that I shouldn't have to provide configuration
 for a Null appender, since it isn't doing anything.  Instead, I have
 to say:
   log4perl.xxx.appender=Null
   log4perl.xxx.layout=NoopLayout
   log4perl.xxx.warp_message=0
 I understand that you're just (properly) checking that people haven't
 made a stupid mistake in forgetting the layout.

Exactly, catching stupid errors has precedence over making slick code
short. :)

-- Mike

Mike Schilli
[EMAIL PROTECTED]

-
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
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] log4perl appenders with warp_message=0

2008-05-13 Thread Mike Schilli
On Tue, 13 May 2008, Erskine, Thomas (IT) wrote:

 I do indeed want

   $logger-log($level, $msg, $key)

 to be dealt with differently depending on the appender it ends up on.
 That's part of the point of having different appenders; they ought to be
 independant.  The problem is that it doesn't seem possible to use
 appenders simultaneously which set (and require) warp_message=0 and ones
 which don't.

I don't think that this is true, warp_message is a per-appender setting
and can be set individually (and differently) per appender. The
restriction is that the you need to use the NoopLayout with the appender
that has warp_message set.

 I've just thought of another way to do this.  If I set
 warp_message=sub{return $_[0]} on the file appender, then things
 should just work.  I don't like putting code in the log configuration
 file, but it's worth a shot.  Just a sec...  Yup.  It works.

That's exactly right -- and since it's per-appender, it won't affect the
other 'fancy' appender. But, the ugly part is that with warp_message
turned on, the appender's log() method gets an a reference to an array
of message chunks, which the file appender can't deal with.

 The problem with using the MDC is that this isn't something which is
 intended to persist for a while.  The whole point is to be able to set
 the Netcool AlertKey on a per-message basis.  Of course I _could_ use
 the MDC, but my usage would look like:

   Log::Log4perl::MDC-put(netcool-key, $key);
   $logger-log($level, $msg);
   Log::Log4perl::MDC-put(netcool-key, undef);

 which isn't exactly handy.

... or you define a wrapper around that:

http://log4perl.sourceforge.net/d/Log/Log4perl.html#6acb7

-- Mike

Mike Schilli
[EMAIL PROTECTED]



  -Original Message-
  From: Mike Schilli [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, May 13, 2008 2:26 AM
  To: Erskine, Thomas (IT)
  Cc: [EMAIL PROTECTED]
  Subject: Re: log4perl appenders with warp_message=0
 
  On Fri, 9 May 2008, Erskine, Thomas (IT) wrote:
 
   The other logs an event to Netcool (specifying
  warp_message=0) and it
   works fine.  It allows you to call log like:
  
   $logger-log($level, $msg, $key)
  
   so that you can specify a Netcool alert key.
  
   Then comes the problem: I made a configuration file including both
   appenders.  Now I lose.  The Netcool appender continues to
  work nicely.
   However, the file appender mashes all the args together if
  I specify
   the key.  Which is the expected behaviour for it, but then
  I can't use
   the key feature with netcool.  I could make it work by setting
   warp_message=0 on the file appender, but to do that I have
  to set the
   layout to NoopLayout, so I can't get nicely formatted log
  entries there.
  
   It seems as if there is no way to use both types of appender (with
   warp_message=0 and without) in the same config file.  Or am
  I missing
   something?
 
  Hi Thomas,
 
  It seems like you want a statement like
 
  $logger-log($level, $msg, $key)
 
  to have two different meanings, depending on which appender
  the message ends up at.
 
  On the Netcool appender, you want it to use the $key for a
  special purpose, on the file appender, you want it to sweep
  $key under the carpet -- seems inconsistent to me, as it's
  not clear what another random new appender would do with this.
 
  For cases like this, I would stuff the Netcool key in the MDC:
 
  http://log4perl.sourceforge.net/d/Log/Log4perl/MDC.html
 
  So instead of saying
 
  $logger-log($level, $msg, $key);
 
  you would say
 
  Log::Log4perl::MDC-put(netcool-key, $key);
  $logger-log($level, $msg);
 
  and the Netcool appender would either fetch the the key from
  the MDC in its log() method and do something with it or you
  could access it as %X{netcool-key} in the layout:
 
 
  http://log4perl.sourceforge.net/d/Log/Log4perl/Layout/PatternL
  ayout.html
 
  Would that work for you?
 
  Can I post this message to the mailing list? Looks like this
  could be useful for other folks as well.
 
  -- Mike
 
  Mike Schilli
  [EMAIL PROTECTED]
 
 

 NOTICE: If received in error, please destroy and notify sender. Sender does 
 not intend to waive confidentiality or privilege. Use of this email is 
 prohibited when received in error.


-
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
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] log4perl causing perl process to die (fwd)

2007-11-05 Thread Strahan, Bob

Thanks Mike..

Looks like the syncer appender has a set of additional module dependencies we 
don't have setup yet in our environment.. I'll try it out when I get a change 
to get things set up.




-Original Message-
From: Mike Schilli [mailto:[EMAIL PROTECTED]
Sent: Sunday, November 04, 2007 3:55 PM
To: Strahan, Bob
Cc: Mike Schilli; log4perl-devel@lists.sourceforge.net
Subject: RE: [log4perl-devel] log4perl causing perl process to die (fwd)

On Sun, 4 Nov 2007, Strahan, Bob wrote:

 We do use the 'close_after_write' option... As I mentioned, there are
 multiple concurrent processes continually being spawned by the
 service, each using log4perl to log to the same logfile.  So we
 figured we needed to use File::Locked along with close_after_write to
 ensure each process got an exclusive lock on the logfile before
 writing to it.

I see -- the recommended ways of synchronizing access to an appender are
listed in the Log4perl FAQ:

http://log4perl.sourceforge.net/d/Log/Log4perl/FAQ.html#23804

I'm not sure how well they work on Windows, though, but give the
'syswrite' option a try, that should be the easiest.

-- Mike

Mike Schilli
[EMAIL PROTECTED]

 Let me know if there is a better (more efficient) way to handle
 multiple concurrent processes logging to the same file e.g. Would
 using socket appenders to route log messages to single log server
 process which handles file i/o from one process be a better option?


  Which version of Windows are you running by the way? On regular XP, it
  seems to work as expected.

 Windows 2003 64-bit server..  I haven't tried it on other flavors of Windows.


 For now I have worked around the problem by inserting the open() call into a 
 retry loop..
 #open $fh, $self-{mode}$self-{filename}
 #or die Cannot write to '$self-{filename}': $!;
 while (1) {
last if open $fh, $self-{mode}$self-{filename} ;
 }








 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mike Schilli
 Sent: Saturday, November 03, 2007 6:32 PM
 To: Mike Schilli
 Cc: log4perl-devel@lists.sourceforge.net
 Subject: Re: [log4perl-devel] log4perl causing perl process to die (fwd)

 On Fri, 2 Nov 2007, Bob Strahan wrote:

  However, it seems that if certain filesystem operations are
  performed on the logfile it can cause the logger to execute die(),
  causing my service to die, with the following error
 
  Cannot write to 'D:/Program Files (x86)/My App/logs/logfile.txt':
  Permission denied at D:\Program Files (x86)\My
  App\lib\perllibs\lib/Log/Dispatch/File.pm line 86.

 Hmm, this is Log::Dispatch::File's _open_file() function complaining
 that an open() failed. Does your service open a files after it's been
 running for a while? Typically, Log::Dispatch::File(::Locked) opens the
 file only once unless 'close_after_write' is given.

 Which version of Windows are you running by the way? On regular XP, it
 seems to work as expected.

 -- Mike

 Mike Schilli
 [EMAIL PROTECTED]

  I am using log4perl in a Win32 service that needs to run forever..  
  However, I have encountered a situation where the logger call is executing 
  a die() and causing my service to die...
 
 
  The service spawns multiple child processes which run concurrently but all 
  log to the same logfile.. We're using File::Locked to avoid contention..  
  Extract from our logger config below..
 
  log4perl.appender.myapp = Log::Dispatch::File::Locked,
  log4perl.appender.myapp.filename = D:/Program Files (x86)/My 
  App/logs/logfile.txt,
  log4perl.appender.myapp.mode = append,
  log4perl.appender.myapp.close_after_write = true,
  log4perl.appender.myapp.permissions = 0660,
  Etc..
 
 

  I can reproduce the problem sporadically by simply opening the logfile in 
  Wordpad..
  I can reproduce it reliably by repeatedly copying the logfile using test 
  script below
 
  #!perl -w
  use File::Copy ;
  while (1) {
 copy (D:/Program Files (x86)/My App/logs/logfile.txt, D:/Program 
  Files (x86)/My App/logs/logfileCOPY.txt) ;
 print . ;
  }
 
 
  Any suggestions on how to defend against users copying or opening the 
  logfile?   We should block and retry until open() suceeds, rather than 
  die(), I think.
 
  Please let me know if you can help with a patch, workaround, or suggestion.
 
  Regards
 
 
 
  Bob Strahan
  HP Software, RD
 
  703.579.1929 office | 702.967.5228 mobile | 702.579.1929 fax | [EMAIL 
  PROTECTED]mailto:[EMAIL PROTECTED]
  10700 Parkridge Blvd. #500 | Reston | VA 20191
 
 
  -
  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
  log4perl-devel@lists.sourceforge.net
  https

Re: [log4perl-devel] Log4perl Categories

2007-08-16 Thread Mike Schilli
On Thu, 16 Aug 2007, Lee Goddard wrote:

 Sometimes I need to just see the logging from a specific
 method/subroutine/function.

 I realize I can change the log levels within that block of code, but
 it would be convenient to be able to say
 log4perl.category.bar.twix.eat to just see the logging from
 Bar::Twix's 'eat' method.  Would it be a bad idea to incorporate this?

Does this third-party CPAN module solve the problem?

http://search.cpan.org/dist/Log-Log4perl-AutoCategorize/

-- Mike

Mike Schilli
[EMAIL PROTECTED]

-
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
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Log4perl Categories

2007-08-16 Thread Berg, Eric
Lee,
 
I use a custom logging class that exports a get_logger($category) that
automatically prepends the namespace hierarchy to the category passed
in, so that I can always do this:
 
My logger config file looks kinda like this:
 
log4perl.logger.MyMods.Action.kgc_dir  = DEBUG, DebugLog
log4perl.logger.MyMods.Action.param= TRACE, DebugLog
log4perl.logger.MyMods.Action.rebless  = TRACE, DebugLog
log4perl.logger.MyMods.ActionRunner.get_status = DEBUG, DebugLog
log4perl.logger.MyMods.ActionRunner.get_status_from_file = TRACE,
DebugLog
log4perl.logger.MyMods.ActionRunner.run= DEBUG, DebugLog
log4perl.logger.MyMods.ActionRunner.status_file_name = TRACE, DebugLog
log4perl.logger.MyMods.Runner.Diff.run = TRACE, DebugLog
log4perl.logger.MyMods.Runner.Diff.get_reference_action = DEBUG,
DebugLog
log4perl.logger.MyMods.Runner.Dummy.run= DEBUG, DebugLog
log4perl.logger.MyMods.Test.get_runner = TRACE, DebugLog
 
Where each of the last items in the category (i.e., kgc_dir, param,
rebless, etc.) are method names in my modules.
 
In each module I just do this:
 
sub my_method {
my $self = shift;
my $log = get_logger('my_method');
 
...
 
}
 
My get_logger looks like this:
 
sub get_logger {
my $category = shift;
my ( $logger, $log_focus, @log_focus );
 
# Initialize if we're not so already
init() unless Log::Log4perl-initialized();
 
# get the caller that we want.
my ( $package, $filename, $line, $subroutine, $hasargs, $wantarray,
$evaltext, $is_require, $hints, $bitmask ) = caller(0);
 
# Put split package name into  @log_focus
@log_focus = split( '::', $package ) if $package;
 
# If there's a category submitted to this sub, append it to
if ($category) {
push( @log_focus, $category );
}
 
$log_focus = join( '.', @log_focus );
 
$logger = Log::Log4perl::get_logger($log_focus);
return $logger;
}
 
There's a bit more to it, but this is the essence.
 
-ERic.



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Lee
Goddard
Sent: Thursday, August 16, 2007 4:21 AM
To: log4perl-devel@lists.sourceforge.net
Subject: [log4perl-devel] Log4perl Categories



Sometimes I need to just see the logging from a specific
method/subroutine/function.

 

I realize I can change the log levels within that block of code, but it
would be convenient to be able to say log4perl.category.bar.twix.eat to
just see the logging from Bar::Twix's 'eat' method.  Would it be a bad
idea to incorporate this?

 

Thanks

Lee

 

Lee Goddard

Senior Software Developer

Advertising.com, London

 

P Think of the environment before you print this email

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- - - -

This message is intended only for the personal and confidential use of the 
designated recipient(s) named above.  If you are not the intended recipient of 
this message you are hereby notified that any review, dissemination, 
distribution or copying of this message is strictly prohibited.  This 
communication is for information purposes only and should not be regarded as an 
offer to sell or as a solicitation of an offer to buy any financial product, an 
official confirmation of any transaction, or as an official statement of Lehman 
Brothers.  Email transmission cannot be guaranteed to be secure or error-free.  
Therefore, we do not represent that this information is complete or accurate 
and it should not be relied upon as such.  All information is subject to change 
without notice.


IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within this 
communication (including any attachments) is not intended or written to be used 
and cannot be used for the purpose of (i) avoiding U.S. tax related penalties 
or (ii) promoting, marketing or recommending to another party any transaction 
or matter addressed herein.
-
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
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel