<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
<shuklaaanjan...@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.de...@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 <shuklaaanjan...@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-unsubscr...@logging.apache.org
> >> For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>

Reply via email to