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
4
votes
2 answers

How can I make log4perl output easier to read?

When using log4perl, the debug log layout that I'm using is : log4perl.appender.D10.layout=PatternLayout log4perl.appender.D10.layout.ConversionPattern=%d [pid=%P] %p %F{1} (%L) %M %m%n log4perl.appender.D10.Filter = DebugAndUp This produces very…
Tom Feiner
  • 20,656
  • 20
  • 48
  • 51
4
votes
1 answer

How can I log only the INFO level in Log4perl?

log4perl has a threshold option in the configuration file that will log all calls that level or higher. Is there an option of setting it log only one type of call? I want to only log calls of level "INFO". Thanks.
Michael Shnitzer
  • 2,465
  • 6
  • 25
  • 34
4
votes
2 answers

How can I suppress output to stdout and stderr in Log4perl?

I have this sub to initialize my logger: sub initLogfiles{ Log::Log4perl->easy_init($INFO); # We log all debug, info, warn, error and fatal messages. my $userlogappender = Log::Log4perl::Appender->new( …
Allan Simonsen
  • 1,242
  • 4
  • 22
  • 37
3
votes
2 answers

How can log4perl write to STDERR and a file at the same time?

I tried to set up two appenders, but it seems to only write to STDERR: my $header = "######$scriptname $version"; use Log::Log4perl qw(:easy); Log::Log4perl->easy_init($DEBUG); my $logger = get_logger(); my $layout =…
shigeta
  • 1,791
  • 3
  • 19
  • 32
3
votes
3 answers

Which script initialized module?

In Perl, is there any way to tell which .pl script has initialized this instance of a module? Specifically, I'd like to get the name of the script calling a module, which has a Log4perl object it. That way, I'll know which .log file I want to write…
Chris Serra
  • 13,226
  • 3
  • 25
  • 25
3
votes
1 answer

Why does USR1 seem to kill Perl, instead of recreating the logfile?

I have a Perl script that I've added logging to, courtesy of Log4perl. The script itself is long-running, and we also need to do log-rotation/archiving on a daily basis. I've opted to use the inbuilt Solaris logadm, rather than using…
victorhooi
  • 16,775
  • 22
  • 90
  • 113
3
votes
1 answer

log4perl: grouping messages

I'm using log4perl to log messages from a perl script. With mwe.pl as below, then I receive the following (desired) output in test.log INFO: some information more information My current implementation uses: my $logmessage = "some…
cmhughes
  • 911
  • 1
  • 8
  • 17
3
votes
1 answer

How can I log the timezone with Log::Log4perl?

We use Log::Log4perl to log the current date like this: log4perl.appender.perllog.layout.ConversionPattern=%d{yyyyMMdd.hhmmss:}-%P-%H-%p{2}-%m Is there a way to log the timezone as well?
Deepanshu Arora
  • 375
  • 1
  • 5
  • 21
3
votes
1 answer

How to print a partial stack trace with Log4perl?

With Log4perl, I know I can include a full stack trace using the %T format string. Is there a way to print a partial stack trace? Say, the first N levels?
3
votes
1 answer

How to set two appenders with different log levels in Log::Log4perl?

I have a logger with two appenders (one Screen and other File). I want to have a Screen appender with a variable log level that can be changed and File appender that will log everything no matter what. So for instance, you can disable any output to…
mocnii
  • 141
  • 6
3
votes
1 answer

Is it possible to register a function to preprocess log messages with Log::Log4perl?

In this example: $logger->debug({ filter => \&Data::Dumper::Dumper, value => $ref }); I can pretty print my references instead of ARRAY(0xFFDFKDJ). But it's too boring to type that long code every time. I just…
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
3
votes
1 answer

Log4Perl bundling logging from several programs into one log

Is there any Logger on CPAN which allows me to bundle logs from several programs into one file with synchronising parallel logging when two programs run the same time and call log4Perl in parallel. Background is that I use a custom appender which…
weismat
  • 7,195
  • 3
  • 43
  • 58
3
votes
1 answer

Perl sigdie handler and eval

I am overriding my SIG die handler as below inside my Logger module. # Catch die messages and log them with logdie $SIG{__DIE__} = \&logdie; Now below program run as expected and post processing will be called. use strict; use warnings; use…
Pungs
  • 2,432
  • 1
  • 16
  • 14
3
votes
1 answer

How to use Log4perl to rotate log files in multithread perl application

Below is the sample code that I have tried to rotate a log file in multithread application using log4perl. But it is working fine unless it is a multithread application. Logs are not rotated and Log file grows in size. Can anyone guide me on where I…
Doe
  • 33
  • 5
3
votes
1 answer

Logging within utility classes

I want to adopt logging within several utility classes, e. g. DBI. What is the best practice to do it with Log::Log4perl? I think it is OK to subclass DBI (say, MyDBI) and override some methods there to make them do the logging. But there's a…
codeholic
  • 5,680
  • 3
  • 23
  • 43