On Mon, 19 Sep 2011, David Christensen wrote:
> I would prefer to enable/ disable TraceApp based on $ENV{REMOTE_ADDR}
> rather than doing all the work and throwing non-192.168.0.34 hits down
> /dev/null, but I couldn't figure out how to implement this idea.
Hi David,
you can use Log4perl's custom filters. If you add
log4perl.filter.MyFilter = sub { $ENV{REMOTE_ADDR} eq '192.168.0.34' }
log4perl.appender.TraceApp.Filter = MyFilter
to your configuration, it'll suppress all messages to the appender that
aren't from your test client.
The Log::Log4perl::Filter manpage explains their use in detail.
Hope that helps!
--
-- Mike
Mike Schilli
[email protected]
> log4perl-devel:
>
> I'm working on a web application and would like to log TRACE priority
> messages related to hits from my development machine (IP address
> 192.168.0.34). This is the relevant portion of my configuration file:
>
> 2011-09-19 12:31:51 dpchrist@p43400e ~
> $ grep TraceApp perl-src/50-Dpchrist-CMS/demo/conf/log4perl.conf
> log4perl.logger = TRACE, InfoApp, TraceApp
> log4perl.appender.TraceApp = Log::Log4perl::Appender::File
> log4perl.appender.TraceApp.filename = sub { $ENV{REMOTE_ADDR} eq
> '192.168.0.34' ? $Mysite::CONF{-log_dir} . '/trace.log' : '/dev/null' }
> log4perl.appender.TraceApp.mode = append
> log4perl.appender.TraceApp.layout = PatternLayout
> log4perl.appender.TraceApp.layout.ConversionPattern =
> %d{yyyyMMdd-HHmmss.SSS} %p %M (%F{1} %L) %m{chomp}%n
> log4perl.appender.TraceApp.Threshold = TRACE
>
>
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel