Thanks Ron:

Thank you for your reply and I really appreciate it.  

May be The getRenderedMessage method in the
LoggingEvent is another place that I can intercept the
log message.  But I'm just beginning to look how to
use log4j and I need to do some more research to find
out how do I overwrite the getRenderedMessage method
to scan and pre-process the message.  Can I extend the
LoggingEvent and do something to have log4j use my
child LoggingEvent method so that I can do what I need
to do with the message.


What I really need to do is to create a utilities to
be used to plug in to the application code so that all
the log message can be scanned/pre-processed before
sending to the Appender.  And of course the
application code need to do the little the better.  


I'm sure the added <renderer> tag in my log4j.xml is
loaded in my server but what I don't understand is
that the doRender method is not get called.  Could
that be because a String object is been bypassed
because it's already a String so that there is no need
to render it again?  I thought the doRender(object o)
will catch all the object.  Is this right?


It this doRender approach the deadend to intercept the
message or I can still catch a String object in
doRender?  


I have changed the renderedClass="java.lang.Object" to
Object instead of String but it's the same thing
doRender method print statement can't be found in my
consoleAppender.

<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/";
  debug="true">
  <renderer renderedClass="java.lang.Object"
        renderingClass="test.log4j.LogCatcher"/> 


Here's the ocnsole log that shows the new <renderer>
tag showned in the logger.

[6/1/07 15:28:09:453 EDT] 0000002a SystemOut     O
log4j: Rendering class: [test.log4j.LogCatcher],
Rendered class: [java.lang.Object].
[6/1/07 15:28:09:453 EDT] 0000002a SystemOut     O
log4j: Level value for root is  [debug].
[6/1/07 15:28:09:453 EDT] 0000002a SystemOut     O
log4j: root level set to DEBUG
[6/1/07 15:28:09:469 EDT] 0000002a SystemOut     O
log4j: Class name: [org.apache.log4j.ConsoleAppender]
[6/1/07 15:28:09:500 EDT] 0000002a SystemOut     O
log4j: Setting property [threshold] to [DEBUG].
[6/1/07 15:28:09:500 EDT] 0000002a SystemOut     O
log4j: Parsing layout of class:
"org.apache.log4j.PatternLayout"
[6/1/07 15:28:09:657 EDT] 0000002a SystemOut     O
log4j: Setting property [conversionPattern] to [%d
%-5p [%t] %C{2} (%F:%L) - %m%n].
[6/1/07 15:28:09:657 EDT] 0000002a SystemOut     O
log4j: Adding appender named [STDOUT] to category
[root].
[6/1/07 15:28:09:672 EDT] 0000002a ServletWrappe A  
SRVE0242I: [TestCsfEAR] [/x] [EntitlementServlet]:
Initialization successful.
[6/1/07 15:28:09:704 EDT] 0000002a SystemOut     O
2007-06-01 15:28:09,704 ERROR [WebContainer : 1]
log4j.EntitlementServlet (EntitlementServlet.java:59)
- log this info !!@@##$$%%^^&&**()++  


--- "Gallagher, Ron" <[EMAIL PROTECTED]> wrote:

> Naider --
> 
> The purpose of Renderers is to generate a String
> representation of an
> Object. Since a String is already a String, there's
> no need to do any
> additional rendering.
> 
> The getRenderedMessage method in the LoggingEvent is
> what is responsible
> for calling any defined renderers.  This method has
> an explicit check
> for situations where the object that's about be
> rendered is an instance
> of String.  In that case, the Object to render is
> simply cast into a
> String and used as-is.
> 
> 
> Ron Gallagher, AT&T Mobility
> 
> 
> -----Original Message-----
> From: Naider Chen [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, May 31, 2007 5:26 PM
> To: Log4J Users List
> Subject: Unable to call doRender. Am I missing
> anything?
> 
> I'm trying to intercept the logging message to
> filter
> some keyword before forwarding to the destination. 
> I
> tested it in a windows environment using RAD6 
> 
> I add the new <renderer> tag entry to log4j.xml and
> put both log4j.dtd and log4j.xml in the
> WEB-INF/classes folder but after I re-compile and
> bounce the server the doRender method was never get
> called.  
> 
> Am I missing snything?  Please help.  Thanks.
> 
> <renderer renderedClass="java.lang.String"
> renderingClass="test.log4j.LogCatcher"/>
> 
> I create a new class test.log4j.LogCatcher as
> follows:
> 
> package test.log4j;
> import org.apache.log4j.*;
> import org.apache.log4j.spi.*;
> import org.apache.log4j.or.ObjectRenderer;
> 
> public class LogCatcher implements ObjectRenderer {
> 
>       public String doRender(Object arg0) {
>               String st = arg0.toString();
>               System.out.println("LogCatcher doRender **********
> log string catched = *" + st + "*");
>               return st;
>       }
> }
> 
> ALWAYS THERE FOR YOU!!!
> Naider Chen
> EMAIL ME ANYTIME!!!!
> 
> 
> 
> 
>        
>
________________________________________________________________________
> ____________
> Choose the right car based on your needs.  Check out
> Yahoo! Autos new
> Car Finder tool.
> http://autos.yahoo.com/carfinder/
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 


ALWAYS THERE FOR YOU!!!
Naider Chen
EMAIL ME ANYTIME!!!!




       
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play 
Sims Stories at Yahoo! Games.
http://sims.yahoo.com/  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to