Questions tagged [log4perl]

Log::Log4perl is a Perl module that lets you remote-control and fine-tune the logging behaviour of your system from the outside.

Log::Log4perl lets you remote-control and fine-tune the logging behaviour of your system from the outside. It implements the widely popular (Java-based) log4j logging package in pure Perl.

111 questions
15
votes
2 answers

How to install and use log4perl?

I am new to using log4p and want to use the same for logging in my code. I am getting errors like: Can't locate Log/Log4perl.pm in @INC Which I understand is because of a missing library. Now, where and how do i get this library installed on my…
learner
  • 365
  • 1
  • 2
  • 14
14
votes
2 answers

How can I catch Perl warnings into Log4perl logs?

Log4perl is a great tool for logging. The warnings pragma is also an essential tool. However, when Perl scripts are running as daemons, the Perl warnings, are printed into STDERR where nobody can see them, and not into the Log4perl log file of the…
Freddie
  • 143
  • 1
  • 5
10
votes
3 answers

How can I rotate and compress Log4perl log files?

From what I can tell neither Log4Perl or any of its related modules in CPAN supports rotate & compression of log files. Rotation can be accomplished by using: Log::Log4perl::Appender::File Log::Dispatch::FileRotate. But neither modules supports…
Tom Feiner
  • 20,656
  • 20
  • 48
  • 51
8
votes
2 answers

Can Perl's Log::Log4perl's log levels be changed dynamically without updating config?

I have a Mason template running under mod_perl, which is using Log::Log4perl. I want to change the log level of a particular appender, but changing the config is too awkward, as it would have to pass through our deployment process to go live. Is…
Will Sheppard
  • 3,272
  • 2
  • 31
  • 41
8
votes
2 answers

Log4perl: How do I dynamically load appenders at runtime?

I'd like to have modules managing their logging at runtime, but without having everything referring to a single monolithic config file. When dealing with processes running under different permissions, I really don't want to deal with each process…
Oesor
  • 6,632
  • 2
  • 29
  • 56
8
votes
2 answers

Making self-logging modules with Log::Log4perl

Is there a way to use Log::Log4perl to make a smart self-logging module that logs its operations to a file even in the absence of the calling script not initializing Log4perl? As far as I can tell from the documentation, the only way to use Log4perl…
Oesor
  • 6,632
  • 2
  • 29
  • 56
7
votes
2 answers

How can I tell if Log4perl emitted any warnings during a run?

I've been using Log4perl extensively in a number of scripts. I'd like to augment those scripts to set an error code if any WARN or ERROR messages have been logged. I couldn't find any obvious way to do this based on existing documentation. I'd like…
pdxrlk
  • 258
  • 1
  • 6
5
votes
1 answer

How can I log to two different files in Log4perl?

I have a Perl script that produces two different streams of data. I need to log them to two separate log files. I'm aware of 2 approaches that result in different log files but neither one seems helpful in my situation: Using categories (which are…
DVK
  • 126,886
  • 32
  • 213
  • 327
5
votes
1 answer

How can I change a log4perl appender's filters at run time?

I'v been trying to figure out if I can change an appender's filter at run-time that I've defined via a configuration file. log4perl.filter.M1 = Log::Log4perl::Filter::LevelMatch log4perl.filter.M2 =…
slm
  • 15,396
  • 12
  • 109
  • 124
5
votes
2 answers

How can I disable Log4perl output for a particular class?

I would like to use Log4perl in a project but disable it for a certain class (which is, in this case Net::Amazon). I thought this would be an easy one, but somehow I failed. I tried using use Log::Log4perl (:easy_init); use Net::Amazon; my $amz =…
Simon
  • 1,643
  • 2
  • 17
  • 23
4
votes
3 answers

How can I use Log4Perl across modules in Perl?

I'm planning to use Log4Perl in my modules for logging. My code structure goes like this I have Start.PL which validates some parameters. I have several modules (PM) file which are interlinked (used across these PL and PM files) I have a Logger.PM…
KK99
  • 1,971
  • 7
  • 31
  • 64
4
votes
4 answers

Disposing of Log4perl logger when I no longer need it

I'm using Log4perl as part of a package to capture what a particular DBI connection is doing. My current plan is to create a new logger object for each connection, via Log::Log4perl->get_logger($mysql_connect_id), which should allow the various…
BlairHippo
  • 9,502
  • 10
  • 54
  • 78
4
votes
2 answers

How can I make log4perl create log directory if it doesn't exist?

If my logging directory (/home/hss/Data/log/DataImport.log) does not exist when log4perl is initializing, then I get this error: Cannot write to '/home/hss/Data/log/DataImport.log': No such file or directory Is there a way to make it create the…
Hari Menon
  • 33,649
  • 14
  • 85
  • 108
4
votes
1 answer

Log all unexpected errors using Log::Log4perl

I want to generate a log for my Perl script. But when I am using Log::Log4perl how can I capture the errors which will be thrown by the script in any case. How to log that to the log file.Currently whatever I write explicitely in variouys tags like…
Mohit
  • 608
  • 4
  • 19
4
votes
1 answer

Log4perl Singleton usage

I'm new to Log4perl and am trying to figure out why I get two different loggers in the below setup. My understanding is that this should be a singleton and calling get_logger() would return the same instance of the object each…
A_B
  • 1,009
  • 3
  • 15
  • 37
1
2 3 4 5 6 7 8