logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: Write a bean to a file
Date Mon, 28 Jan 2008 21:34:27 GMT

On Jan 28, 2008, at 1:24 PM, Tim Nguyen wrote:

> Hi,
> I am a newbie of Log4j. I wonder if anyone has an example or an  
> utility of how to write a bean to a file using Log4j. Thank you!

Not quite sure what you are asking.  You can pass any Object as the  
message parameter.  Unless you register an ObjectRenderer for that  
specific type, then that Object's toString() method will be called to  
get a rendered string for formatting.  If you register an  
ObjectRenderer, then that class will be used to create the text  
representation of the object.

That is:

SomeBean bean = ....

is typically equivalent to:

SomeBean bean = ....

You can specify an class implementing  
org.apache.log4j.or.ObjectRenderer to be used to render a specific  
class by configuring it in the configuration file or  
programmatically.  Programmatically, should look something like:

logger.getRepository()).addRenderer("com.example.MyBean", new  

I'm not sure how it would look in a configuration file and can't find  
a ready example, but I'm not going to dig on it unless that is what  
you want to do and nobody else speaks up.

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

View raw message