Hello Monks,
I was introduced today to the impressive Log::Log4perl. It looks really impressive and in order to give it a try I tried to implement it straight on one of my Perl scripts.
What I can not figure out is why I am getting this error:
Log::Log4perl configuration looks suspicious: No loggers defined at /u +sr/local/share/perl/5.18.2/Log/Log4perl/Config.pm line 322.
I tried to follow the instructions found on the CPAN page and create my own Log::Log4perl Conf file.
Sample of the Log::Log4perl Conf file:
###################################################################### +######### # Log::Log4perl Conf + # ###################################################################### +######### log4perl.rootLogger = DEBUG, LOG1, SCREEN log4perl.appender.SCREEN = Log::Log4perl::Appen +der::Screen log4perl.appender.SCREEN.stderr = 0 log4perl.appender.SCREEN.layout = Log::Log4perl::Layout: +:PatternLayout log4perl.appender.SCREEN.layout.ConversionPattern = %d %p %m %n log4perl.appender.LOGFILE = Log::Log4perl::Ap +pender::File log4perl.appender.LOGFILE.filename = /home/errorLog4Pe +rl.log log4perl.appender.LOGFILE.mode = append log4perl.appender.LOGFILE.layout = Log::Log4perl::La +yout::PatternLayout log4perl.appender.LOGFILE.layout.ConversionPattern = [%r] %F %L %m%n
The log file exists and I am calling the module in several points e.g. $logger->info("this is an info log test message"); and also in other places such as:
open $stdout_fh[$num] , '>' , "".$hashRefDir->{Directories}{log_dir}." +/".$hashRefconf->{$mp}{log}."" or $logger->error("unable to create file: $hashRefconf->{$mp}{ +log} - $!");
This is my configuration inside the subroutine that I am calling the module:
# Initialize Logger Log::Log4perl::init($logConf->{Log4Perl}{logConfIniFile}); my $logger = Log::Log4perl->get_logger("parallelSsh");
Does anyone knows the reason that the log messages are not written in the errorLog4Perl.log?
Answer/ Solution: I needed to spend some time but I manage to find the reason that I was getting the error. I was loading the log4perl.log file instead of the log4perl.conf file. I hope the solution will assist in future other users with the same problem.
.Thank you in advance for your time and effort.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |