logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Deboy <scott.de...@gmail.com>
Subject Re: Modifying the content to be shown in log files using properties files by blacklisting charters
Date Fri, 07 Oct 2011 20:45:39 GMT
<appender name="F1" class="org.apache.log4j.FileAppender">
       <param name="file" value="c:/temp/file.txt"/>
       <param name="append" value="false"/>
       <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%p %c - p1:%X{p1}
p2:%X{p2} %m%n"/>
       </layout>
     </appender>


     <appender name="A1" class="org.apache.log4j.rewrite.RewriteAppender">
       <appender-ref ref="F1"/>
       <rewritePolicy class="org.apache.log4j.rewrite.PropertyRewritePolicy">
         <param name="properties" value="p1=Hello,p2=World,x1=3.1415"/>
       </rewritePolicy>
     </appender>

   <root>
      <level value="debug"/>
       <appender-ref ref="A1" />
    </root>


You implement your own RewritePolicy and define its class in place of the
'PropertyRewritePolicy' and modify the loggingEvent in the rewrite method of
the RewritePolicy implementation..

Scott

On Fri, Oct 7, 2011 at 1:21 PM, aanjaneya shukla
<shuklaaanjaneya@gmail.com>wrote:

> Can you please guide me to any examples, it would be lot quicker.
>
> Thanks,
> Aanjaneya
>
> On Fri, Oct 7, 2011 at 8:28 PM, Scott Deboy <scott.deboy@gmail.com> wrote:
> > Yes it is possible to modify log messages before they are sent to an
> > appender. Use a rewriteappender, implement you own rewritepolicy, and
> > include an appender-ref to the destination appender in the
> rewriteappender
> > definition along with the rewritepolicy.
> >
> > Scott
> >
> >
> >
> > On Oct 7, 2011, at 7:37 AM, aanjaneya shukla <shuklaaanjaneya@gmail.com>
> > wrote:
> >
> >> Hi,
> >>
> >> To avoid log injection by newline charters, is it possible to modify
> >> the contents of user defined messages in the log files? I want to
> >> black list certain charters defined in the property file its with
> >> adding any code to my framework.
> >>
> >> Thanks,
> >> Aanjaneya.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message