I want to create a log for my Perl script. But when I use Log :: Log4perl , how can I fix errors that will be thrown by the script anyway. How to write this to a log file. Currently, everything that I write explicitly in different tags, such as ERROR (), DEBUG (), etc., is the only one that is printed in the log file.
Is there a way to do this using Log :: Log4perl.
An example in the code below:
use strict;
use warnings;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init( { level => $DEBUG,
file => ">>test.log" });
my $logger = Log::Log4perl->get_logger();
$logger->fatal( "This is", " fatal");
$logger->error( "This is error");
$logger->warn( "This is warn");
$logger->info( "This is info");
$logger->debug( "This is debug");
$logger->trace( "This is trace");
my $a = 10;
my $b = $a/0;
A division by zero error is not logged in the script. Mine original script is too complicated to check for every error, so you want something that also logs the error to stderr in the log file.