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

2013-03-16 Thread Lee
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-16 Thread Alexander Hartmaier
On Fri, Mar 15, 2013 at 11:29 AM, Dmitry Bigunyak  wrote:

> Yes, that's actually how I see it, get the raw data, format them to a
> certain type and pass to an appender.
> As a matter of fact, this is exactly what Layouts allow me to do. I was
> wrong saying that they are meant to render strings only. If fact you get an
> array ref with all raw data inside the render() method. Maybe this is a bit
> which is missing in the FAQ, "How can I write my own layout?". :)
> So, I can implement my own Layout::JSON or/and Layout::XML and use them
> with different appenders which working with strings. Nice! The only thing
> I'm missing here is the ability to use built in layouts like PatternLayout
> when I want to dump JSON to a log file as a formatted string. Or another
> example, compressing the data before passing them to the appender. 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. But maybe this is a controversial
> feature request and should be discussed in a separate thread.
>
> /Dmitry
>
> Пятница, 15 марта 2013, 8:01 +01:00 от Lee < [email protected] >:
> > Sorry to reply to such a long and thoughtful e-mail with a URI, but do
> > you think being given access to the raw data would give you sufficient
> > means to format it?
> >
> >
> http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl/FAQ.html#e8a46
> >
> > Could you then forward the formatted data to an appender of your
> > choice/via appenders listed in the config?
> >
> > Lee
> >
>
> --
> 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
>

You might want to check out Message::Passing [1],
Log::Dispatch::Message::Passing [2] to get your Log4perl messages into it
and my Message::Passing::Output::Log::Any::Adapter [3] for the other
direction.
I wrote it to use Message::Passing to parse syslog messages and mail them
using Log4perl with Log::Dispatch::Email.

Keep us updated because I'm planning to push the log messages of all my
Log4perl based Catalyst and MooseX::App::Cmd apps to a central log store,
probably ElasticSearch and am interested in your use case and solution.

[1] https://metacpan.org/module/Message::Passing
[2] https://metacpan.org/module/Log::Dispatch::Message::Passing
[3] https://metacpan.org/module/Message::Passing::Output::Log::Any::Adapter
--
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] Error when re-initializing log4perl

2013-03-16 Thread Marc Zampetti
The use case is the situation where I don't know what the config file with
the logging configuration is yet. So basically, the program does the
following:

1. Initializes the logging system as soon as it starts, before anything
else, with a basic config that will log to stdout.
2. Process the command line parameters, does some other configuration work,
which includes figuring out where the correct logging configuration file
is. I need a valid logging system because there may be cases in this phase
that log messages get generated, say for missing information or a
filesystem permission issue, etc.
3. Calls init() with the new config file, to setup the real logging that
should be done for the rest of the application.

I cannot use the init_and_watch() method, because I don't have a config
file to use yet. Not to mention, the init_and_watch has some performance
issues.

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.

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
>> log4perl-devel@lists.**sourceforge.net
>> 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