David, one way you can do this is by attaching a filter to your TraceApp
appender, like this

   log4perl.filter.NotIfDevIP =  sub { $ENV{REMOTE_ADDR} eq '192.168.0.34' ?
0 : 1 }
   log4perl.appender.TraceApp.Filter = NotIfDevIP

See 'perldoc Log::Log4perl::Filter'


On Mon, Sep 19, 2011 at 9:39 PM, David Christensen <
dpchr...@holgerdanske.com> wrote:

> 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
>
>
> 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.
>
>
> Is there a better way?
>
------------------------------------------------------------------------------
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
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to