[log4perl-devel] Error when re-initializing log4perl

2013-03-15 Thread Marc Zampetti
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


Re: [log4perl-devel] Structured logging in log4perl

2013-03-15 Thread Dmitry Bigunyak
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


Re: [log4perl-devel] Structured logging in log4perl

2013-03-15 Thread Lee
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

On 14/03/2013 17:25, Dmitry Bigunyak wrote:
> Hi there!
>
> I was searching the mailing-list history but didn't find any topics related 
> to the subject I'd like to discuss. Maybe I didn't look close enough, sorry 
> if so.
> Anyway, the subject I want to discuss is how to use log4perl for structured 
> logging.
> There are a couple of modules on CPAN related to this task, like for example 
> Log::Log4perl::Layout::GELF, Log::Log4perl::Appender::Fluent or 
> Log::Message::JSON. But different approaches implemented there gave me the 
> impression that there is no a general convenient way of doing structured 
> logging in log4perl.
> Yes, you can pass an arbitrary list of parameters to the logger and it really 
> depends on the appender if it can work with that or not,  
> Log::Log4perl::Appender::DBI is a good example of how to do that. But what if 
> I want to log my data to database, log file and lets say ElasticSearch at the 
> same time. The problem here is that all three appenders expect data in 
> different formats, File appender expects to get a string, DBI - a list of 
> parameters and ElasticSearch - JSON. This is the place where you get stuck 
> and has to choose something one.
> The Log::Message::JSON module, as I understand it, is trying to address the 
> problem using objects which get serialized to JSON in appenders expecting 
> stings. But calling a special function (logmsg) every time you log something 
> is quite a hassle and this is only JSON, what if I want to use XML? Here we 
> go, there is no way in log4perl you can format you data before they are 
> passed to appender. Layouts are meant to render messages, not arbitrary data. 
> I also was trying to play with the warp_message appender option but it's 
> result is always an array ref which doesn't work with File appender for 
> example and it's probably not the best way to solve the problem.
> To don't introduce new entities I'd say that Layouts is a proper place to 
> make such transformations but it is just not how things work now.
>
> Can someone suggest a good solution for that or maybe an idea?
> What are you thoughts in general on the problem, should it be solved in 
> log4perl?
> Thanks.
> --
> Dmitry
> e-mail: [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


--
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