thanos1983 has asked for the wisdom of the Perl Monks concerning the following question:

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.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re: Log::Log4perl configuration looks suspicious: No loggers defined
by Anonymous Monk on May 18, 2015 at 23:12 UTC

    Does anyone knows the reason that the log messages are not written in the errorLog4Perl.log?

    Its almost impossible to know without a self-contained example

    If I try to load the config file you posted I get ERROR: you didn't tell me how to implement your appender 'LOG1'

    Try again please

      Oh, I figured it out, an empty file says Log::Log4perl configuration looks suspicious: No loggers defined

        Hello Anonymous Monk,

        Apologies for the late reply. I finally found what I was doing wrong. I was loading the *.log file instead of the *.conf. That was the reason that I was getting this mistake. I will update my question hopping to assist other people in getting confused with these minor problem.

        Thank you for your time and effort.

        Seeking for Perl wisdom...on the process of learning...not there...yet!

      Hello Anonymous Monk,

      Apologies for the late reply. I finally found what I was doing wrong. I was loading the *.log file instead of the *.conf. That was the reason that I was getting this mistake. I will update my question hopping to assist other people in getting confused with these minor problem. I have also removed the LOG1 you are right about that comment.

      Thank you for your time and effort.

      Seeking for Perl wisdom...on the process of learning...not there...yet!