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
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
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?
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel