NAME

Log::Log4perl::CommandLine - Simple Command Line Interface for Log4perl

SYNOPSIS

use Log::Log4perl qw(:easy); # to get constants

# Some alternatives:

use Log::Log4perl::CommandLine;
use Log::Log4perl::CommandLine { level => $INFO };
use Log::Log4perl::CommandLine { layout => '%d %c %m%n' };
use Log::Log4perl::CommandLine { level => $WARN, layout => '%d %c %m%n' };
use Log::Log4perl::CommandLine qw(/my/default/log.conf);
use Log::Log4perl::CommandLine \q(...some log4perl config...);

# These configure the root logger:

my_program.pl --verbose                # sets root logger to INFO
my_program.pl -v                       # sets root logger to INFO
my_program.pl --debug                  # sets root logger to DEBUG
my_program.pl -d                       # sets root logger to DEBUG
my_program.pl --quiet                  # sets root logger to OFF
my_program.pl -q                       # sets root logger to OFF

# Or you can configure a specific category:

my_program.pl --verbose Some::Module
my_program.pl --debug Broken::Module

# You can have multiple options, or separate by commas:

my_program.pl --verbose Module1 --verbose Module2
my_program.pl --verbose Module1,Module2

# Simple changes to log configuration:

my_program.pl --logconfig /another/log.conf  # Command line override

my_program.pl --logfile /path/log.txt        # Add a simple file logger

my_program.pl --logfile "log.file|%d %m%n"   # Optional layout override

# Complete list of log level options:
# debug, info (verbose), warn, error, fatal, off (quiet)

DESCRIPTION

Log::Log4perl::CommandLine parses some command line options, allowing for simple configuration of Log4perl using the command line, or easy, temporary overriding of a more complicated Log4perl configuration from a file.

The <use Log::Log4perl> line is needed if you want to use the constants ($ERROR, $INFO, etc.) or what to use Log4perl logging in your program (which you should). If a main program doesn't use Log4perl, but uses modules that do, you can just add one line use Log::Log4perl::CommandLine; and everything will just work.

Any options parsed and understood by this module are stripped from @ARGV (by Getopt::Long), so they won't interfere with later command line parsing.

Be very careful with naming of other options though, since this module takes over a bit of option space.

BUGS

Experimental for comments, interface may change.

AUTHOR

Curt Tilmes, <ctilmes@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2008 by Curt Tilmes

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.