Re: [log4perl-devel] Error when re-initializing log4perl

2013-03-17 Thread Mike Schilli

On Sat, 16 Mar 2013, Marc Zampetti wrote:


So basically the question I have is that I need to reset and
re-configure the logging system at some point after the initial
logging setup. The docs for the init() and init_once() methods suggest
that calling init() a second time will "reset" and "overwrite" the
current configuration, which in this case I want.


Can you try if calling

Log::Log4perl->reset()

before calling init() the second time fixes the problem?

-- -- Mike

Mike Schilli
[email protected]

In the test suite, 


I hope that helps.

On Sat, Mar 16, 2013 at 4:08 AM, Lee  wrote:
  I don't know the L4p source, but I vaguely recall that
  someone, years ago, possibly in the Log4perl docs, said that
  the init method was only intended to implement
  initialisation, not re-initialisation.

  I may be wrong — I can't imagine ever calling init() twice,
  though I did occasionally do it when I first started using
  the system, there was some now-forgotten issue that stopped
  the practice.

  Why are you calling init twice?

  If it is just in case the config has chanced, there is an
  init-and-watch method.

  If it is to combine configurations, the Hash::Merge module
  can help, and there is a working example somewhere in the
  archives of this group.

  HTH

  On 15/03/2013 21:54, Marc Zampetti wrote:
  I have a program that configures a basic Log4perl
  config so that I have
  some sane logging until I'm able to read in the config
  file with the
  final configuration. I'm getting an error when calling
  Log::Log4perl->init() the second time that I cannot
  seem to track down.

    From the reading of the docs, this is a valid use
  case. Its a pretty
  basic perl script, not using fork() or threads or
  anything, and running
  from the commandline, not mod_perl or something like
  that.

  The error I get is:

  Can't call method "log" on an undefined value at
  /usr/lib/perl5/vendor_perl/5.8.8/Log/Log4perl/Appender.pm
  line 189.

  This is generated when I do the second
  Log::Log4perl->init(filename)
  call. The first call to init passes in a string with
  the basic
  configuration.

  Anyone have any ideas what the issue might be?

  I'm running Log4perl-1.40, using Red Hat 5 64-bit.

---
---
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel




--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Structured logging in log4perl

2013-03-17 Thread Mike Schilli
On Fri, 15 Mar 2013, Dmitry Bigunyak wrote:

> That brings me to the idea of having a chain of layout (in current 
> terminology) when you get an actual result passed through a number of 
> layouts and formatted in each of them accordingly.

Have you looked at composite appenders yet?

 
http://search.cpan.org/~mschilli/Log-Log4perl-1.40/lib/Log/Log4perl/Appender.pm#Composite_Appenders

You can use a composite appender to preprocess the message and have it
forwarded to the target appender right after.

For the type of processing you have in mind, I've originally put
warp_message in place, but I agree that the fact that it always produces
an array ref isn't helpful. Maybe we need another preprocess hook for
appenders in Log4perl.

-- 
-- Mike

Mike Schilli
[email protected]

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel