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!

In reply to Log::Log4perl configuration looks suspicious: No loggers defined by thanos1983

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.