これを行うには、confファイルでカスタムcspecを指定します。
# basic config to write the log to a file
log4perl.logger.mylog = DEBUG, MyLog
log4perl.appender.MyLog = Log::Log4perl::Appender::File
log4perl.appender.MyLog.filename = my.log
# create a custom cspec called 'A' with an anonymous sub.
# The sub would be called with the following args: $layout, $message, $category, $priority, $caller_level
# Then apply the regex as you like.
log4j.PatternLayout.cspec.A = sub { $_[1] =~ s/module/package/; $_[1] }
# then use the cspec here with '%A'
log4perl.appender.MyLog.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.MyLog.layout.ConversionPattern = %A%n
そして、コードを変更する必要はありません。
use Log::Log4perl;
log::Log4perl::init('log.conf');
my $logger = Log::Log4perl->get_logger('mylog');
$logger->info("Testing the logger module"); # prints 'Testing the logger package'