>From the PropertyConfigurator javadoc: "You can customize the way message objects of a given type are converted to String before being logged. This is done by specifying an ObjectRenderer for the object type would like to customize. The syntax is:
log4j.renderer.fully.qualified.name.of.rendered.class=fully.qualified.name.o f.rendering.class As in, log4j.renderer.my.Fruit=my.FruitRenderer" This means that for your ResultObject class you need to write a ResultObjectRenderer class implemeting the org.apache.log4j.or.ObjectRenderer interface, and register the renderer in the config file in order for Log4j to recognize it, e.g: log4j.renderer.com.core.client.ResultObject=com.core.client.ResultObjectRend erer. This will instruct Log4j to use an instance of ResultObjectRenderer to stringify ResultObject instances instead of using the default toString() method. Note that ResultObjectRenderer must have a public default constructor. Hope this helps. -- Thomas | -----Original Message----- | From: write2vishu [mailto:[EMAIL PROTECTED] | Sent: 01 January 1601 00:00 | To: [EMAIL PROTECTED] | Subject: log4j ObjectRenderer. | | | Hi, | | I am working on log4j for some project. | Currently in the project,the outgoing and incoming messages are logged | as Strings via 'resultObject.toString()'.This doesn't allow the use of | Log4J Object Renderers.I want to log the message as | 'resultObject' Object itself so that | ObjectRenderers can be used to format the output as required. | I have done the following changes in the java file. | Note :- This is a patch of java code specific to log4j from the source | code. | | ------------------------------------------------------------------ | ------------// File : example.java | package com.core.client; | | //Following package i have imported for log4j. | import org.apache.log4j.Category; | import org.apache.log4j.PropertyConfigurator; | import org.apache.log4j.or.RendererMap; | import org.apache.log4j.or.ObjectRenderer; | | | private static Category log = Category.getInstance(example.class); | | //Changed the log.debug( resultObject.toString() ) statements to | log.debug(resultObject); | | | ------------------------------------------------------------------ | ------------Do i need to make any more changes in the java file | to use Object | Renderer ? | I found in the log4j document that we need to make following entry in | the log4j.properties file :- | log4j.renderer.my.package.name.MyClassToLog=my.otherpackage.name.M | yRendererClass | But i couldn't understand what should be 'my.package.name.MyClassToLog' | and 'my.otherpackage.name.MyRendererClass' for the above given java file? | Any help on this will be appreciated. | | Thanks & Regards, | Vishweshwar. | | | --------------------------------------------------------------------- | To unsubscribe, e-mail: [EMAIL PROTECTED] | For additional commands, e-mail: [EMAIL PROTECTED] | | ************************************************************************* Copyright ERA Technology Ltd. 2003. (www.era.co.uk). All rights reserved. The information supplied in this Commercial Communication should be treated in confidence. No liability whatsoever is accepted for any loss or damage suffered as a result of accessing this message or any attachments. ________________________________________________________________________ This email has been scanned for all viruses by the MessageLabs Email Security System. For more information on a proactive email security service working around the clock, around the globe, visit http://www.messagelabs.com ________________________________________________________________________ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]