You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Gallagher, Ron" <RG...@att.com> on 2007/06/01 17:15:10 UTC

RE: Unable to call doRender. Am I missing anything?

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:naider2@yahoo.com] 
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: 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


Re: help to extend PatternLayout

Posted by James Stauffer <st...@gmail.com>.
What are you trying to accomplish?

On 6/23/07, Naider Chen <na...@yahoo.com> wrote:
> Hi:
>
> I'm trying extend PatternLayout in order to intercept
> log message.
>
> The foremat method basically return all the log
> message included in the ConversionPattern.  I'd like
> to get the %m and do some pre-process and return it.
> I'm not sure this is the way to get %m can anybody
> help me with this.
>
> Thanks.
>
> Naider
>
>
>
> ____________________________________________________________________________________
> Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
> http://smallbusiness.yahoo.com/webhosting
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
James Stauffer        http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


help to extend PatternLayout

Posted by Naider Chen <na...@yahoo.com>.
Hi:

I'm trying extend PatternLayout in order to intercept
log message.

The foremat method basically return all the log
message included in the ConversionPattern.  I'd like
to get the %m and do some pre-process and return it. 
I'm not sure this is the way to get %m can anybody
help me with this.

Thanks.

Naider


       
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhosting 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Unable to call doRender. Am I missing anything? Please help

Posted by Naider Chen <na...@yahoo.com>.
Hi Curt:

Thanks for your clarification on this.  I'm really
appreciate.  At least I know where to focus now.

I need to capture all log4j rendered message as String
and remove something from the message if necessary to
address an issue of log injection attack.

I can get the same kind of your results now after
making some changes to that render example.  But the
String has been bypassed in the doRender.   I have
tried the
<renderer renderedClass="java.lang.Object"
<renderer renderedClass="java.lang.String"

I guess the doRender() method is the deadend for my
purpose.

The filter that I tried is not useful either since
LoggingEvent object I can use to do
getMessage()/getRenderedMessage() but there is no
setMessage()/setRenderedMessage() in log4j version
1.2.14 to change the message for me so that it's not
useful to my purpose.

   <appender name="STDOUT"
class="org.apache.log4j.ConsoleAppender">
    <param name="Threshold" value="debug" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern"
        value="%d %-5p [%t] %C{2} (%F:%L) - %m%n" />
    </layout>
    <filter
class="com.test.logging.log4j.filter.MyStringFilter"/>
  </appender>

I'll start to look what I can do with Layouts for the
message %m.  I'm new to this area and I'm not sure
where to start with Layouts to intercept the %m in the
Layouts but I'll start to do some searching for it.

Can Layouts be able to alter message or if I can get a
quick example to see how to use it to get to the
message part.  Also can I do something so that Layouts
can be extended to apply to all the appender in one
shot or I need to customize the Layout for each
Appender?

Thanks again for your assistance.

Naider

--- Curt Arnold <ca...@apache.org> wrote:

> 
> On Jun 6, 2007, at 9:59 AM, Naider Chen wrote:
> 
> > Hi:
> >
> > Can any one confirm to me it's working to call
> > doRender() method.  I'll appreciate if you can
> provide
> > me a successful example if you do make it work.  I
> use
> > log4j-1.2.14 in RAD6 and put log4j.xml in the
> > WEB-INF/classes folder and I'm sure the added
> > <renderer> has been loaded.
> 
> 
> There is an ORTestCase in the test suite (and which
> currently  
> passes), but the tests are inadequate to ensure that
> doRender is  
> being called in normal processing.
> 
> >
> > I tried the complete example from
> >
> > http://www.java2s.com/Code/Java/Language-Basics/ 
> > log4jAcompleteexample.htm
> >
> >
> > but the doRender() was never got called and it's
> not
> > calling to my own test to add <renderer> to the
> > log4j.xml and extend ObjectRenderer in my render
> class
> > with doRender() method.
> >
> > I just have to know if this is the right way to
> call
> > doRender() and capture the message to change it.
> 
> There are a multitude of errors in that sample, but
> if you fix all of  
> them, the OrderRenderer.doRender is called using
> log4j 1.2.14.  To  
> get the sample to run, I needed to:
> 
> Remove non-breaking spaces from the source
> Make all the classes "public" and place them in
> separate files named  
> after the classes.
> Extract the sample configuration file from the end
> of the sample and  
> name it log4j.xml
> Remove the asterisks used to comment out the
> configuration file
> remove the space between <renderer> and </renderer>
> Change the name of the logger in the configuration
> from  
> "com.apress.logging.log4j" to "name"
> Remove all the com.apress.* package names from the
> configuration file  
> since the Java source did not have any package
> statements.
> 
> If you did that, the output of the sample program
> was:
> 
> main INFO  name - Beer-101-20
> main INFO  name - Chocolate-223-5
> 
> If you commented out the renderer element, you got:
> 
> main INFO  name - CustomerOrder@b000e7
> main INFO  name - CustomerOrder@b76fa
> 
> >
> > I tried what Ron has suggested me to use
> LoggingEvent
> > object to filter the message to do getMessage()
> and
> > getRenderedMessage().  but it's not good to me
> since
> > there are no setRenderedMessage() to alter the
> message
> > that I want to return.
> >
> 
> >
> >
> > --- Naider Chen <na...@yahoo.com> wrote:
> >
> >> 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.
> >>
> 
> You needs would appear to be better served with
> either a Filter or  
> Layout.  An object renderer would only get invoked
> when a object  
> other than a String is passed as the message and
> custom renderer is  
> associated with the type.  Filters or Layouts would
> see all logging  
> requests, an ObjectRenderer would only see the
> subset that uses your  
> special type.
> 
> >>
> >> 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?
> >>
> 
> There is a check in
> LoggingEvent.getRenderedMessage() that bypasses  
> rendering if the message is already a string.  That
> behavior can't be  
> changed at this date.  You can't use an
> ObjectRenderer to manipulate  
> the message, however you may be able to use a Layout
> to get what you  
> want.
> 
> >>
> >> 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.
> 
> The rendered class is used as a key into a map of
> renders in  
> org.apache.log4j.or.RendererMap.findAndRender(). 
> When searching for  
> a renderer the value from msg.getClass() is used on
> the lookup, so a  
> Renderer will only match precisely the class
> specified as the  
> rendered class.  So if a renderer is registered for 
> 
> "java.lang.Object", the renderer would only get
> invoked if you were  
> making calls like:
> 
> logger.debug(new Object());
> 
> >>
> >> <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" <RG...@att.com> 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
> >>>
> 
> That's right.
> 
> 
> 
> 
> >>>
> >>> -----Original Message-----
> >>> From: Naider Chen [mailto:naider2@yahoo.com]
> >>> 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;
> >>> 	}
> >>> }
> >>>
> 
> 
> 
> Might be good if you try to explain exactly what you
> are trying to  
> do.  From what you describe, it seems like a Filter
> or Layout is much  
> better fit than an ObjectRenderer.
> 
> 
> 
> 
> 



       
____________________________________________________________________________________
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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Unable to call doRender. Am I missing anything? Please help

Posted by Curt Arnold <ca...@apache.org>.
On Jun 6, 2007, at 9:59 AM, Naider Chen wrote:

> Hi:
>
> Can any one confirm to me it's working to call
> doRender() method.  I'll appreciate if you can provide
> me a successful example if you do make it work.  I use
> log4j-1.2.14 in RAD6 and put log4j.xml in the
> WEB-INF/classes folder and I'm sure the added
> <renderer> has been loaded.


There is an ORTestCase in the test suite (and which currently  
passes), but the tests are inadequate to ensure that doRender is  
being called in normal processing.

>
> I tried the complete example from
>
> http://www.java2s.com/Code/Java/Language-Basics/ 
> log4jAcompleteexample.htm
>
>
> but the doRender() was never got called and it's not
> calling to my own test to add <renderer> to the
> log4j.xml and extend ObjectRenderer in my render class
> with doRender() method.
>
> I just have to know if this is the right way to call
> doRender() and capture the message to change it.

There are a multitude of errors in that sample, but if you fix all of  
them, the OrderRenderer.doRender is called using log4j 1.2.14.  To  
get the sample to run, I needed to:

Remove non-breaking spaces from the source
Make all the classes "public" and place them in separate files named  
after the classes.
Extract the sample configuration file from the end of the sample and  
name it log4j.xml
Remove the asterisks used to comment out the configuration file
remove the space between <renderer> and </renderer>
Change the name of the logger in the configuration from  
"com.apress.logging.log4j" to "name"
Remove all the com.apress.* package names from the configuration file  
since the Java source did not have any package statements.

If you did that, the output of the sample program was:

main INFO  name - Beer-101-20
main INFO  name - Chocolate-223-5

If you commented out the renderer element, you got:

main INFO  name - CustomerOrder@b000e7
main INFO  name - CustomerOrder@b76fa

>
> I tried what Ron has suggested me to use LoggingEvent
> object to filter the message to do getMessage() and
> getRenderedMessage().  but it's not good to me since
> there are no setRenderedMessage() to alter the message
> that I want to return.
>

>
>
> --- Naider Chen <na...@yahoo.com> wrote:
>
>> 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.
>>

You needs would appear to be better served with either a Filter or  
Layout.  An object renderer would only get invoked when a object  
other than a String is passed as the message and custom renderer is  
associated with the type.  Filters or Layouts would see all logging  
requests, an ObjectRenderer would only see the subset that uses your  
special type.

>>
>> 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?
>>

There is a check in LoggingEvent.getRenderedMessage() that bypasses  
rendering if the message is already a string.  That behavior can't be  
changed at this date.  You can't use an ObjectRenderer to manipulate  
the message, however you may be able to use a Layout to get what you  
want.

>>
>> 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.

The rendered class is used as a key into a map of renders in  
org.apache.log4j.or.RendererMap.findAndRender().  When searching for  
a renderer the value from msg.getClass() is used on the lookup, so a  
Renderer will only match precisely the class specified as the  
rendered class.  So if a renderer is registered for  
"java.lang.Object", the renderer would only get invoked if you were  
making calls like:

logger.debug(new Object());

>>
>> <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" <RG...@att.com> 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
>>>

That's right.




>>>
>>> -----Original Message-----
>>> From: Naider Chen [mailto:naider2@yahoo.com]
>>> 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;
>>> 	}
>>> }
>>>



Might be good if you try to explain exactly what you are trying to  
do.  From what you describe, it seems like a Filter or Layout is much  
better fit than an ObjectRenderer.





RE: Unable to call doRender. Please help

Posted by Naider Chen <na...@yahoo.com>.
Hi;

I'm running short of time trying to figure out the
right approach to capture the log4j message and remove
something from the message if necessary to address an
issue of log injection attack.

There are some earlied thread talked about using
doRender method but I don't know if they ever get it
worked out.

http://mail-archives.apache.org/mod_mbox/logging-log4net-user/200410.mbox/%3CDDEB64C8619AC64DBC074208B046611C1FFD2C@kronos.neoworks.co.uk%3E

http://mail-archives.apache.org/mod_mbox/logging-log4j-user/200607.mbox/%3C3FE38194C8A3334A959B64B7D9A1E27B6E3152@plejaden.seychelles.ergo%3E

I tried to get help from Log4J User community but not
have good luck on this issue.  If anyone from the
Log4J developer community knows it's the way to call
doRender() to pre-process the message rendering and it
works in your experience please help me out with this.
 I just can't get my doRender() method called but I'm
sure the new added <renderer> is loaded from my
log4j.xml.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration
xmlns:log4j="http://jakarta.apache.org/log4j/"
  debug="true">
<renderer
renderedClass="com.apress.business.CustomerOrder"
renderingClass="com.apress.logging.log4j.renderer.OrderRenderer"/>

> log4j: Threshold ="null".
> log4j: Rendering class:
> [com.apress.logging.log4j.renderer.OrderRenderer],
> Rendered class: [com.apress.business.CustomerOrder].
> log4j: Level value for root is  [debug].
> log4j: root level set to DEBUG
> log4j: Class name:
> [org.apache.log4j.ConsoleAppender]

Or may be there are other ways to capture log4j
message to change it other than using doRender()
method.  Please give me some clue.

I know there is LoggingEvent object I can use to do
getMessage()/getRenderedMessage() but there is no
setMessage()/setRenderedMessage() in log4j version
1.2.14 to change the message for me so that it's not
useful to my purpose.


Thanks very much for your attention.

Naider

--- Naider Chen <na...@yahoo.com> wrote:

> Hi:
> 
> Can any one confirm to me it's working to call
> doRender() method.  I'll appreciate if you can
> provide
> me a successful example if you do make it work.  I
> use
> log4j-1.2.14 in RAD6 and put log4j.xml in the
> WEB-INF/classes folder and I'm sure the added
> <renderer> has been loaded.
> 
> I tried the complete example from 
> 
>
http://www.java2s.com/Code/Java/Language-Basics/log4jAcompleteexample.htm
> 
> 
> but the doRender() was never got called and it's not
> calling to my own test to add <renderer> to the
> log4j.xml and extend ObjectRenderer in my render
> class
> with doRender() method. 
> 
> I just have to know if this is the right way to call
> doRender() and capture the message to change it.
> 
> I tried what Ron has suggested me to use
> LoggingEvent
> object to filter the message to do getMessage() and
> getRenderedMessage().  but it's not good to me since
> there are no setRenderedMessage() to alter the
> message
> that I want to return.
> 
> Thanks.
> 
> Naider
> 
> 
> log4j: Threshold ="null".
> log4j: Rendering class:
> [com.apress.logging.log4j.renderer.OrderRenderer],
> Rendered class: [com.apress.business.CustomerOrder].
> log4j: Level value for root is  [debug].
> log4j: root level set to DEBUG
> log4j: Class name:
> [org.apache.log4j.ConsoleAppender]
> log4j: Setting property [threshold] to [DEBUG].
> log4j: Parsing layout of class:
> "org.apache.log4j.PatternLayout"
> log4j: Setting property [conversionPattern] to [%d
> %-5p [%t] %C{2} (%F:%L) - %m%n].
> log4j: Adding filter of type [class
> com.test.logging.log4j.filter.MyStringFilter] to
> appender named [STDOUT].
> log4j: Adding appender named [STDOUT] to category
> [root].
> enter MyDemo
> %%%enter DtccStringFilter decide
> %%%DTCC getMessage string is captured *test this
> string*
> %%%DTCC getRenderedMessage string is captured *test
> this string*
> 2007-06-06 10:52:25,551 INFO  [main] log4j.MyDemo
> (MyDemo.java:20) - test this string
> 
> 
> --- Naider Chen <na...@yahoo.com> wrote:
> 
> > 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" <RG...@att.com> 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:naider2@yahoo.com] 
> > > 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:
> > > 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
> > > 
> > > 
> > 
> > 
> > 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:
> > log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail:
> > log4j-user-help@logging.apache.org
> > 
> > 
> 
> 
> 
>        
>
____________________________________________________________________________________
> Need a vacation? Get great deals
> to amazing places on Yahoo! Travel.
> http://travel.yahoo.com/
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> 
> 





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




       
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell. 
http://searchmarketing.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


RE: Unable to call doRender. Am I missing anything? Please help

Posted by Naider Chen <na...@yahoo.com>.
Hi:

Can any one confirm to me it's working to call
doRender() method.  I'll appreciate if you can provide
me a successful example if you do make it work.  I use
log4j-1.2.14 in RAD6 and put log4j.xml in the
WEB-INF/classes folder and I'm sure the added
<renderer> has been loaded.

I tried the complete example from 

http://www.java2s.com/Code/Java/Language-Basics/log4jAcompleteexample.htm


but the doRender() was never got called and it's not
calling to my own test to add <renderer> to the
log4j.xml and extend ObjectRenderer in my render class
with doRender() method. 

I just have to know if this is the right way to call
doRender() and capture the message to change it.

I tried what Ron has suggested me to use LoggingEvent
object to filter the message to do getMessage() and
getRenderedMessage().  but it's not good to me since
there are no setRenderedMessage() to alter the message
that I want to return.

Thanks.

Naider


log4j: Threshold ="null".
log4j: Rendering class:
[com.apress.logging.log4j.renderer.OrderRenderer],
Rendered class: [com.apress.business.CustomerOrder].
log4j: Level value for root is  [debug].
log4j: root level set to DEBUG
log4j: Class name: [org.apache.log4j.ConsoleAppender]
log4j: Setting property [threshold] to [DEBUG].
log4j: Parsing layout of class:
"org.apache.log4j.PatternLayout"
log4j: Setting property [conversionPattern] to [%d
%-5p [%t] %C{2} (%F:%L) - %m%n].
log4j: Adding filter of type [class
com.test.logging.log4j.filter.MyStringFilter] to
appender named [STDOUT].
log4j: Adding appender named [STDOUT] to category
[root].
enter MyDemo
%%%enter DtccStringFilter decide
%%%DTCC getMessage string is captured *test this
string*
%%%DTCC getRenderedMessage string is captured *test
this string*
2007-06-06 10:52:25,551 INFO  [main] log4j.MyDemo
(MyDemo.java:20) - test this string


--- Naider Chen <na...@yahoo.com> wrote:

> 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" <RG...@att.com> 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:naider2@yahoo.com] 
> > 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:
> > 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
> > 
> > 
> 
> 
> 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:
> log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> 
> 



       
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: Unable to call doRender. Am I missing anything?

Posted by Naider Chen <na...@yahoo.com>.
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" <RG...@att.com> 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:naider2@yahoo.com] 
> 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:
> 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
> 
> 


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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org