I fear I have a question answered easily so I must demonstrate that I have done the proper work before coming here for help. I have searched PM's database of questions for log4perl (went down 3 pages). I've googled the question and read tutorials here and here. I've also asked 2 colleages (although they were basing their answers off of log4j). This is my first brushes with log4j or log4perl.

If I have a rootLogger defined for priority of ERROR, and then another logger (let's call logger a) defined for priority of INFO, am I correct in thinking that a call to logger a with a message of priority INFO will trigger only logger a's appenders and not rootLogger because rootLogger has a priority of ERROR? Because if so, that's certainly not the case. Please help explain this to me!

The conf file
############Root############ log4perl.rootLogger=ERROR, A1 log4perl.appender.A1=Log::Log4perl::Appender::File log4perl.appender.A1.filename=error.log log4perl.appender.A1.mode=write log4perl.appender.A1.layout=PatternLayout log4perl.appender.A1.layout.ConversionPattern=[%d{ABSOLUTE}] %p %c - % +m%n ############File only ############# log4perl.logger.fileLogger=INFO, LOGFILE log4perl.appender.LOGFILE=Log::Log4perl::Appender::File log4perl.appender.LOGFILE.filename=log.log log4perl.appender.LOGFILE.mode=write log4perl.appender.LOGFILE.layout=PatternLayout log4perl.appender.LOGFILE.layout.ConversionPattern=[%d{ABSOLUTE}] %p % +c - %m%n
The perl code
use warnings; use strict; use Log::Log4perl qw(get_logger); Log::Log4perl->init("log.conf"); my $log = get_logger("fileLogger"); $log->debug("Log only Debug message"); $log->info("Log only Info message"); $log->error("Log only Error message"); $log->logwarn("Log only We have hit a warning\n");
output of log.log
[system]$ cat log.log [14:06:36,001] INFO fileLogger - Log only Info message [14:06:36,001] ERROR fileLogger - Log only Error message [14:06:36,002] WARN fileLogger - Log only We have hit a warning
Output of error.log - and here is where the output is unexpected
[system]$ cat error.log [14:06:36,001] INFO fileLogger - Log only Info message [14:06:36,001] ERROR fileLogger - Log only Error message [14:06:36,002] WARN fileLogger - Log only We have hit a warning


Lastly I read that "categories are also called "Loggers" in Log4perl, both refer to the the same thing and these terms are used interchangeably". Does this mean log4perl.logger.fileLogger and log4perl.category.fileLogger are the same thing?

In reply to log4perl inheritance by fidesachates

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.