multithreadingperllog4perl

Perl Error with Log::Log4perl::Appender::File


I am trying to build application with the help of Perl. The application consists of Thread::Pool and Log4Perl packages from perl.

When i exclude package Thread::Pool logging works. But when i include it it gives me error as following:

ERROR: can't load appenderclass 'Log::Log4perl::Appender::File'
Could not find file for 'Log::Log4perl::Appender::File' at C:/Perl/site/lib/load.pm line 214.

Working Code :

# use Thread::Pool;
use Log::Log4perl;

my $log_conf = 'LoggingConfiguration.conf';
Log::Log4perl::init($log_conf);
my $logger = Log::Log4perl->get_logger();
$logger->info(" Info Msg ");

But if i remove comment as

use Thread::Pool;

it gives above error

What is the exact reason for this to happen? How to avoid this error?


Solution

  • From some searching around, it appears that there are problems with Thread::Pool's use of the use load pragma:

    From the Thread::Pool bug tracker:

    When creating object under perl 5.8.8, adding 'use Thread::Pool' is causing issues when items are being blessed. Specifically, in many instances code that normally returns values and that are then blessed show up as null. Removing the 'use load' pragma from Thread::* fixes the issue.

    Thread::Pool on cpanratings:

    This module is indeed convenient, but in my opinion there are some serious problems with it. [ ... ] Second, this module is using 'use load' which causes Log::Log4perl to malfunction. That is certainly one evil heisenbug. It was only because I found a Czech comment in this source file (http://w2c.martin.majlis.cz/w2c/doc-gen/crawler_8pl_source.html - link broken) that it didn't take me days of debugging.

    Thread::Pool issues with Log4Perl on PerlMonks - unresolved, but answers include:

    Do not use Thread::Pool. It is buggy. Switch to Thread::Queue. (OP's response: problems persisted with Thread::Queue)

    You also might try Thread::Pool::Simple. I've had better luck with that than Thread::Pool.

    So the consensus is either try removing use load from Thread::Pool, or use a different module.