Resent of my posting from 24 Feb which seems to have been lost.
- Original message -
From: Ronald Fischer yn...@mm.st
To: Mike Schilli m...@perlmeister.com
Cc: Mike Schilli m...@perlmeister.com, log4perl MailingList
log4perl-devel@lists.sourceforge.net
Date: Tue, 24 Feb 2009 09:52:06 +0100
Subject: Re: [log4perl-devel] Appender::File and Layout question
On Mon, 23 Feb 2009 08:34 -0800, Mike Schilli m...@perlmeister.com
wrote:
The other problem is that I would strongly prefer a solution without
l4p configuration file. The reason is that one requirement for our
application was one config file only, so we have an application
specific configuration file, so I'm using easy_init to initialize the
logging.
Everything you can do in a configuration file can be done in code with
the Log4perl API, problem is just that it might get confusing if you're
trying to figure out what's going on by looking at the configuration
file, while application code is pulling the rug under it :).
Right, but this is a decision I don't want to (actually, I must not)
decide by myself, but this must be done by the project leader, which
means that I have to at least demonstrate both ways. Thanks to your
explanations, I understand how to do it in a config file, but I don't
see how to do it in my code. Probably it is not possible at all with
easy_init (which I would like to continue to use) - at least I can't
find anything suitable in the perldoc of Log::Log4perl.
There is something in the section Advanced Perl Configuration, but
I don't see how to use it in my case. This is how far I got:
# This is my current initialization
Log::Log4perl-easy_init(
# ... Details left out
);
# Now define the request-specific logger
use Log::Log4perl::Layout;
use Log::Log4perl::Level;
my $req_logger= Log::Log4perl-get_logger(???);
my $req_appender = Log::Log4perl::Appender-new(
Log::Log4perl::Appender::File,
name = ???,
mode = 'clobber',
utf8 = 1,
create_at_logtime = 1
filename = \get_current_logfile); # ???
$req_appender-layout(Log::Log4perl::Layout::PatternLayout-new(...));
$req_logger-add_appender($req_appender);
$req_logger-level($INFO);
And when it comes to logging something to the request logger, I would
write i.e.
$req_logger-loginfo(my message goes here);
I don't know whether the general idea is right or whether there is a
shorter way
to write it, but still there are a few open points, which I have marked
in my
code above with ???.
First, what category string should I pass to get_logger? We don't work
with
categories, and we have none defined with easy_init, so it would make
sense
to me to pass the default category. Could this be done by passing,
say, the
null string?
Second, what is the name parameter used for when creating the
Appender. I found
the usage of name = in the perldoc, but what's its purpose?
Finally, is my usage of passing a code reference to filename correct?
Kind regards,
Ronald
-- Mike
Mike Schilli
m...@perlmeister.com
--
Ronald Fischer rona...@eml.cc
+ If a packet hits a pocket on a socket on a port,
+ and the bus is interrupted and the interrupt's not caught,
+ then the socket packet pocket has an error to report.
+ (cited after Peter van der Linden)
--
Ronald Fischer rona...@eml.cc
+ If a packet hits a pocket on a socket on a port,
+ and the bus is interrupted and the interrupt's not caught,
+ then the socket packet pocket has an error to report.
+ (cited after Peter van der Linden)
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel