Here's a nice new Log4perl extension that just made it to CPAN:
-- Mike Mike Schilli [EMAIL PROTECTED] ---------- Forwarded message ---------- From: Curt Tilmes <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Log4perl command line options Date: Mon, 4 Aug 2008 16:27:27 -0400 I attended your talk at OSCON about Log4perl (which I enjoyed immensely, thank you!), and asked a question about command line options rather than config files. I've thought about it a bit since then, and put together the attached module. Everything is still in flux. This isn't intended to replace the configuration file interface (which is infinitely more configurable), but rather to make an easy way to 1) make use of Log4perl even if you don't want to think about the config files (or teach end users how to write them), and 2) provide an easy command line way to override a couple parts without continually editing/saving a new config file. What do you think about the proposed module name: Log::Log4perl::CommandLine As implemented, I just call Getopt::Long to do all the command line option parsing, but I know you don't want to add dependencies on external modules for your core Log4perl module. This could be released independently if that was a concern. To illustrate, I took the simple "drink soda" script from one of your tutorial articles and changed it like this: ================================= use Log::Log4perl qw(:easy); use Log::Log4perl::CommandLine; drink(); drink("Soda"); sub drink { my($what) = @_; my $logger = get_logger(); if(defined $what) { $logger->info("Drinking ", $what); } else { $logger->error("No drink defined"); } } ================================== Now it is command line enabled, and you can do things like this: % perl log.pl 2008/08/04 15:55:53 No drink defined % perl log.pl -v (or --verbose) 2008/08/04 15:55:56 No drink defined 2008/08/04 15:55:56 Drinking Soda % perl log.pl -q (or --quiet) % perl log.pl --debug --logfile log.txt 2008/08/04 16:08:16 No drink defined 2008/08/04 16:08:16 Drinking Soda % cat log.txt 2008/08/04 16:08:16 No drink defined 2008/08/04 16:08:16 Drinking Soda % perl log.pl --trace My::Module [...] What do you think? Curt
CommandLine.pm
Description: Binary data
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel