I appreciate the help and I know about the documentation. I have been reading all that I can and trying to implement what is being discussed. Clearly, I am not understanding something and I would like some specific code direction.

I took the advice and tried to use the init() method. Here is my attempt:

use Log::Log4perl; sub init() { my %log_conf = ( "log4perl.logger.STDOUT" => "DEBUG, STDOUT", "log4perl.logger.FILE" => "DEBUG, FILE", "log4perl.appender.STDOUT" => "Log::Log4perl::Appender: +:Screen", "log4perl.appender.STDOUT.stderr" => "0", "log4perl.appender.STDOUT.layout" => "Log::Log4perl::Layout::P +atternLayout", "log4perl.appender.STDOUT.layout.ConversionPattern" => "%d %p> + %F{1}:%L %M - %m%n", "log4perl.appender.FILE" => "Log::Log4perl::Appender: +:File", "log4perl.appender.FILE.filename" => "test.log", "log4perl.appender.FILE.mode" => "append", "log4perl.appender.FILE.layout" => "Log::Log4perl::Layout::P +atternLayout", "log4perl.appender.FILE.layout.ConversionPattern" => "%d %p> % +F{1}:%L %M - %m%n" ); Log::Log4perl->init(\%log_conf); } sub getLogger { my ($category) = @_; my $logger = Log::Log4perl->get_logger($category); return $logger; } sub modify_logger { my ($level) = @_; Log::Log4perl->appender_by_name('FILE')->{min_level} = $level; Log::Log4perl->appender_by_name('FILE')->{filename} = "file2.log"; ${Log::Log4perl::Logger::APPENDER_BY_NAME{'FILE'}}->{min_level} = +$level; ${Log::Log4perl::Logger::APPENDER_BY_NAME{'FILE'}}->{filename} = " +test2.log"; my $logger_appender = ${Log::Log4perl::Logger::APPENDER_BY_NAME{'F +ILE'}}; my $appenders = Log::Log4perl->appenders(); my $appender = Log::Log4perl->appender_by_name('FILE'); print; } init(); modify_logger('TRACE'); my $stdout_logger = getLogger(STDOUT); $stdout_logger->trace("testing stdout logger"); my $file_logger = getLogger(FILE); $file_logger->trace("testing file logger"); print

I can query and modify the appenders in the modify_logger() function (I can see the changes in my debugger), but the logging behavior does not change. How can I change the values AND the behavior?

I have been banging my head against this problem and I could really use some specific help.

Thank you


In reply to Re^4: log4perl help by drohr
in thread log4perl help by drohr

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.