I would expect the code in Tools.pm to log, but it does not. Couldn't quite restrict it to 20 lines, it is as short as I could get it:

the parent process:
#!/usr/local/nik/ess2/perlbrew/perls/perl-5.22.2/bin/perl -w use strict; use lib '/testmod'; use Tools; use Log::Log4perl; my $conf = q( log4perl.category.ess2_loader=DEBUG, LOGFILE log4perl.category.Tools.run_test=INFO, LOGFILE log4perl.appender.LOGFILE=Log::Log4perl::Appender::File log4perl.appender.LOGFILE.filename=/testmod/debug.log log4perl.appender.LOGFILE.mode=append log4perl.appender.LOGFILE.layout=PatternLayout log4perl.appender.LOGFILE.layout.ConversionPattern=%d %P [%r] %F % +L %c - %m%n ); Log::Log4perl::init( \$conf ); my $log = Log::Log4perl::get_logger("ess2_loader"); $log->info("logging successfully"); run_monitor( { foo => 'bar', baz => 'foobar' } ); sub run_monitor { my $href = shift; $log->info("trying to spawn child for periodic check..."); if (my $ps = fork) { $log->info("successfully spawned PID $ps"); $SIG{CHLD} = "IGNORE"; } else { $log->info("running check as PID $$"); Tools::run_tests($href); } }

The module called from the child:

use warnings; use strict; package Tools; use Log::Log4perl; my $log = Log::Log4perl::get_logger("Tools::run_test"); my $href = shift; sub run_tests { foreach my $test (keys %{$href}) { $log->info("running test $test with parameters $href->{$test}" +); } exit; } 1;

Whether I define the category as category.Tools or category.Tools.run_tests makes no difference in this example.

To my understanding category settings propagate to sub-categories, unless these are defined with their own settings. That's why I originally defined the category as 'Tools', to cover all subroutines in Tools.pm


In reply to Re^2: Gettign a logger with Log::Log4perl by nikmit
in thread Gettign a logger with Log::Log4perl by nikmit

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.