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

How can I report the line number with Log4perl and Moose?

Is it possible to get Log4perl to correctly display the line number and package/class of the log event instead of always Method::Delegation at line 99 when used with Moose? In my case, I have created an attribute isa Log::Log4perl::Logger and…
user269820
  • 33
  • 4
3
votes
2 answers

How to get Log4perl rotating my logs daily?

I'm reading up on Log4perl and want to try and use it for simple log management of my Perl scripts running on a Linux box. I've also read up on newsyslog and logrotate but want to use Log4perl if at all possible. I'm trying to configure the…
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756
3
votes
1 answer

Log4perl category as log file name

I'm sure I'm being dim and missing the obvious but is there a simple way of using the current category as the filename in a config file without resorting to a subroutine call? So that in the following one could use ${category}.log instead of…
user1833431
  • 37
  • 1
  • 1
3
votes
2 answers

Limiting log size with log4perl

I want to limit the size of log files created with log4perl. I don't want my log file to grow to more than about 100mb; I only need the last 100mb (or thereabouts) of data. Ideally, it would truncate earlier data and only keep the last bits. I'm…
Rachel
  • 83
  • 1
  • 8
2
votes
1 answer

Can a single perl script running in background hold multiple instances of Log4Perl?

I have a script "server.pl" which is running in background and which is self-logging using Log4Perl. This script continuously reads in a directory and detects new files created in it with Linux::Inotify2 module. Each detected file is a Storable…
tony
  • 618
  • 1
  • 6
  • 12
2
votes
2 answers

How can I mock Log::Log4perl::INFO?

I'm writing new unit tests for an existing module that uses Log::Log4perl like: use Log::Log4perl qw(:easy); The module calls INFO( "important message" );. I'd like to mock this to verify from my test code that INFO is called in certain…
bstpierre
  • 30,042
  • 15
  • 70
  • 103
2
votes
2 answers

Can I write some results to a file using Log::Log4perl without depending on the default levels?

I want to log some results into a file withot messing with the leves of my logs. Is it possible to do that with Log::Log4perl. I have tried to follow the documentation, but I only was able to find that it depends on the log level to printo a file?…
nck
  • 1,673
  • 16
  • 40
2
votes
2 answers

Read console output of a shell script in Perl

Let's say I've got a shell script called print_error.sh looking like this: #!/usr/bin/bash echo "ERROR: Bla bla, yada yada." exit 1 Now I'm in a Perl script, calling this shell script with system("print_error.sh") I now want to read the console…
user321068
2
votes
1 answer

Using Log::Log4perl with MCE (Many-core Engine) Perl

I am using MCE for parallel processing for one of my project. I am facing issue while logging the output from MCE (for logging I am using Log4perl). I have gone through the examples provided and found them printing to STDOUT/STDERR or to some log…
rai-gaurav
  • 536
  • 1
  • 8
  • 19
2
votes
3 answers

Self logging Perl modules (without Moose)

I have the same question as was asked HERE but unfortunately I cannot install Moose and I think the solution described there was particular to Moose. Can someone tell me how to the same in old school "use base" speak? To reiterate the question, I…
stephenmm
  • 2,640
  • 3
  • 30
  • 48
2
votes
2 answers

log4perl one logger with two appenders and different loglevels

I'm trying to log into two different files on different loglevels using a single logger: perl.pl use Log::Log4perl; Log::Log4perl::init('log4perl.conf'); my $logger =…
feumw
  • 151
  • 9
2
votes
0 answers

Combining log4j and log4perl logs

I have a Java application that launches a Perl program using Runtime.exec, waits for it to return and then continues. I would like the log4j output from the Java application and the log4perl output from the Perl program to go to the same file. In…
AJ11
  • 21
  • 2
2
votes
0 answers

How to log to diferent files with Log4perl

In perl, is there a way to log to two different files in different path? For example, I have to log detailed server queries and responses in a file and flow of the script in other file (the second file will have just the abstract information). How…
Bala Krishnan
  • 374
  • 3
  • 18
2
votes
1 answer

Log4perl: how to switch to other-named log file on the fly?

I am the author of the Log4perl::KISS module, and I want to convert the log_open function so that it can switch the current log file on the fly at any time without full Log::Log4perl reinitialization. I know that the file appender in Log4perl can…
drvtiny
  • 705
  • 3
  • 13
2
votes
1 answer

Defining multiple log levels in Log4Perl

I have the following log4perl.conf configuration file that I'm using for multiple scripts. It is configured to show messages from all log levels. # Log4perl configuration file log4perl.rootLogger = ALL, screen, file log4perl.appender.screen =…
A_B
  • 1,009
  • 3
  • 15
  • 37