Finding an alternative to Log4perl for concurrent logging from multiple processes

I need a logging module with a simple interface to log messages from multiple processes to a shared local log file.

Since some of these processes can run concurrently, the logging engine must manage conflicting write requests from this process.

I know about Log::Log4perl

, but every time I try to use it, I end up with an extremely complex logging interface. I am looking for an alternative. Any suggestions?

I have looked through Log::Message

which AFAICT is the only registration module included in Perl composite modules (unfortunately IMO). I didn't find any indication that it handles concurrency at all.

I also tried to find CPAN for an alternative, but just looks for "Log ::" in modules generated over 3000 hits, in a specific order. Even scanning this list is impractical, let alone reading the documentation for possible candidates and trying out those that seem promising. (I wonder if the difficulty of finding a reasonable enrollment unit in CPAN is really what makes people roll their own, which they submit later to CPAN, thus adding another element to the already unmatched mountain of enrollment units. IOW, we may have a case of runaway growth here.)

I'm looking for a simple interface. Ideally, all customization (such as log file path, log level, etc.) would be done through the global shared config file ~/.*rc

and / or environment.

Here is an example of what I mean by "simple interface" (although of course I do not expect to find a module there that offers this exact interface, and of course EasyLog

is the made name if a module with that name already exists. that's a coincidence):

#!/usr/bin/env perl

# some/

use strict;
use EasyLog ':all';


DEBUG "cwd: " + Cwd::cwd();


WARN "skipping empty line $.";


FATAL "timeout";  # maybe calls exit ?


Then in some file $ENV{ EASYLOG_PATH }

I would see lines like

30031   1430599390  /path/to/some/ 2   INFO    Starting on Sat May  2 16:43:10 2015
30031   1430599429  /path/to/some/ 19  WARN    skipping empty line 898
30036   1430599542  /path/to/some/ 2   INFO    Starting on Sat May  2 16:45:42 2015
30031   1430599583  /path/to/some/ 94  INFO terminated normally on Sat May  2 16:46:23 2015
30036   1430599583  /path/to/some/ 32  FATAL   timeout



source to share

1 answer

Log :: Any with Log :: Any :: Adapter :: File should do the trick.

use Log::Any::Adapter (
    File => $ENV{ EASYLOG_PATH }
    log_level => 'warn',


Install this in your application. Any modules your application uses are

use Log::Any qw( $log );


Later, if you want to go to Log4perl

, you only need to change the operator use Log::Any::Adapter




All Articles