Jul 13

Log::Any has finally been released to CPAN. It allows CPAN modules to log messages in a generic way, while letting the application choose (or decline to choose) a logging mechanism such as Log::Dispatch or Log::Log4perl.

This is something I’ve been meaning to implement for nearly two years – talk about procrastination! What pushed me over the edge was that three of my distributions – Mason, CHI, and an upcoming Server::Control – all needed to log various things, and had no good generic way to do it.

As part of this effort, I surveyed the various general-purpose logging packages on CPAN to see which ones Log::Any should interface with. Log::Dispatch and Log::Log4perl were the heavyweights and obvious first choices, but I was unprepared for the sheer variety of other distributions. Logging, like templating systems, seems to be one of those things that everyone wants to try their hand at. Here’s a partial list of logging packages that all share roughly the same mission – dispatching logs to various outputs – along with the number of distributions that depend on each:

Log::Log4perl 176
Log::Dispatch 40
Log::Agent 18
Log::Report 16
Log::Trace 13
Log::Dispatch::Config 9
Log::Message 5
Log::Channel 3
Log::Dump 3
Log::Handler 2
Log::Info 2
Log::LogLite 1
Log::FileSimple 1
Log::Message::Simple 1
Log::StdLog 1
Log::Simple -
Log::Simplest -
Log::Tiny -
Log::Trivial -

I particularly like that there are seven packages named with a variation of “Simple”, “Trivial”, etc. Trying to choose between these would be the opposite of simple.

To be fair, Log::Dispatch, presumably the easier of the two main logging packages to configure, requires this just to log normally to a file:

   my $dispatcher = Log::Dispatch->new();
           name      => 'foo',
           min_level => 'info',
           filename  => "$dir/test.log",
           mode      => 'append',
           callbacks => sub { my %params = @_; "$params{message}n" },
   $dispatcher->info('this is a message');

It’s no wonder people tried this and yearned for a simpler alternative. (I’ve gotten permission from Dave to simplify a few of these things with a maintenance release.)

2 Responses to “Log::Any released, only two years late”

  1. Robin Smidsrød Says:

    You forgot my Log::UDP::Client (and ::Server).

  2. jonswar Says:

    That’s an interesting one. I was listing just the generic logging packages that go to a variety of common sources (file, screen, etc.), not the special purpose packages such as yours – should have made this more clear.

preload preload preload