The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Changes for version 0.21

  • Synopsis shows code samples in Log4perl.pm/README
  • Slight Log4j incompatibility but useful: %F{n} lets you limit the number of entries the source file path is logged
  • Erik W. Selberg (erik@selberg.com) suggested having PatternLayout.pm suppress another \n if the messages already contains a \n and the format requires a %n. Done.
  • Erik W. Selberg (erik@selberg.com) suggested loggers should take any number of messages and concatenate them. Done.
  • Fixed double-init problem and added a test case. Now the entire configuration is cleared before the second init(). However, this surfaced a problem with init_and_watch: If a program obtains references to one or more loggers, rewriting the configuration file during program execution and re-initing makes these reference point to loggers which hold obsolete configurations. Fixed that by code in debug(), info(), etc. which *replaces* (shudder) the logger reference the program hands in to them with a new one of the same category. This happens every time if 'init_and_watch' has been enabled. However, this introduces a small runtime penalty. This is different from the original log4j, which does some half-assed re-initialization, because Java isn't expressive enough to allow for it. Making this thread-safe might be tough, though.
  • Added DEBUG statements to Logger.pm and Config.pm to trace execution (debugging won't work because of "eval"s). Both files define a constant named DEBUG towards the top of the file, which will have perl optimize away the debug statements in case it's set to 0.
  • A warning is issued now (once) if init() hasn't been called or no appenders have been defined.
  • Added ':levels' target to Log::Log4perl to import $DEBUG, $ERROR, etc. levels (just like 'use Log::Log4perl::Level' works).
  • Added ':easy' target to allow for simple setup
  • Messages can be passed in as subroutines to avoid parameter passing penalty

Modules

Log4j implementation for Perl
Log appender object
maps java log4j appenders to Log::Dispatch classes
wraps Log::Dispatch::Screen
wraps Log::Dispatch::File
Predefined log levels
Main Logger
Appender class for testing

Provides

in lib/Log/Log4perl/Config.pm
in lib/Log/Log4perl/Layout.pm