On Thu, 16 May 2013, Mark Horstmeier wrote:

Log4perl loads with level set to ERROR per conf.  I want to set my
appender to DEBUG Threshold was not defined in the conf so it is set
to ALL I set the appender to DEBUG But still only the ERROR and FATAL
levels are output

Looks like you're setting the appender's threshold when what you really
want is setting the logger's level instead. Doesn't

     my $logger = Log::Log4perl::get_logger('');

     # ...
     $logger->level( $DEBUG );

do what you have in mind?

-- -- Mike

Mike Schilli
m...@perlmeister.com

A follow up question on thresholds I have a web app (application
engine) that returns different mime-types depending on the  query.  I
use a screen appender to embed the debug logs in the response (usually
javascript, because I often return javascript for the client browser
to execute). 

When I need to return JSON, the javascript debug 
      // <log4perl stuff>

Blows up the JSON encoding.  

If I just use $logger->level(..) to keep the debug from leaking into my JSON
document, I lose the debug information that is written to my file appender.

When I return javascript, embedding the debug in the javascript is very
helpful to the people apps for my application engine so they can debug the
creation of the javascript so I don't want to eliminate it.

I have tried to change the threshold dynamically on just one appender, but
the log out put remains the same (I am testing this with just a file
appender for simplicity):
  my $logger = Log::Log4perl::get_logger('');
    DEBUG("debug");
    INFO("info");
    WARN("warn");
    ERROR("error");
    FATAL("fatal");  
...
    my $appender =  $Log::Log4perl::Logger::APPENDER_BY_NAME{$key};
    my $dthresh = $appender->threshold();    
    $logger->error("Appender set to: ",Log::Log4perl::Level::to_level(
$dthresh ));
    my $nthresh = $appender->threshold($DEBUG);
...
    $logger->error("Appender set to: ",Log::Log4perl::Level::to_level(
$n2thresh ));
    $logger->debug("debug");
    $logger->info("info");
    $logger->warn("warn");
    $logger->error("error");
    $logger->fatal("fatal");

With my conf file:
       log4perl.logger = ERROR, FileApp

log4perl.appender.FileApp           = Log::Log4perl::Appender::File
log4perl.appender.FileApp.filename  = /web/logs/detail_log
log4perl.appender.FileApp.mode = append
log4perl.appender.FileApp.owner = web
log4perl.appender.FileApp.group = web
log4perl.appender.FileApp.utf8 = 1
log4perl.appender.FileApp.layout =
Log::Log4perl::Layout::PatternLayout
log4perl.appender.FileApp.layout.ConversionPattern = \
%r %X{eid} %p %F{1} %X{site} %X{rule} %m%n

Apache gives me this:
      3 [undef] ERROR Configure.pm [undef] [undef] error
      4 [undef] FATAL Configure.pm [undef] [undef] fatal
      5 [undef] ERROR Configure.pm [undef] [undef] Appender set to:
      ALL

 
      5 [undef] ERROR Configure.pm [undef] [undef] DEBUG FileApp 

 
      6 [undef] ERROR Configure.pm [undef] [undef] Appender set to:
      DEBUG
      6 [undef] ERROR Configure.pm [undef] [undef] error
      6 [undef] FATAL Configure.pm [undef] [undef] fatal


...

I suppose that an alternative would be to apply a Buffer composite appender
and only creating the trigger condition if the response type is not JSON

Should I be able to make this work via threshold or do I need to pursue an
alternative solution?

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to