The ObjectRenderers are primarily used to convert custom
LoggingEvent.Message objects into strings. This is designed to allow
users to log their own custom objects and have control over how they are
rendered for logging (i.e. differently to their objects ToString
method).

The PropertyPatternConverter uses WriteObject. WriteObject on
log4net.Util.PatternConverter will use an object renderer if it has a
repository available. If it does not have a repository then it will do
some default rendering. Typically it would have a repository and that
should not be an issue.

This means that a Property value can also contain custom objects that
are rendered by an ObjectRenderer.

The ObjectRenderer is not designed to be a general extension point, but
just a way of converting unknown object types to strings. The date
patterns think they know enough about the date value to render it to a
string themselves, therefore these do not use the ObjectRenderers.
The ObjectRenderer is focused on turning objects into strings, therefore
it contains a number of shortcuts. For example it cannot be used to
render a string type because it is already a string and the RendererMap
just returns the input immediately.

Nicko

> -----Original Message-----
> From: Ron Grabowski [mailto:[EMAIL PROTECTED] 
> Sent: 17 October 2005 02:26
> To: [email protected]
> Subject: When _can't_ I use a layout renderer?
> 
> PropertyPatternConverter uses WriteObject in its Convert 
> method. I'm fairly certain that within WriteObject, the 
> object to be output is tested to see if it has a layout 
> render for it. Is this the case for all objects output? 
> Converters like DatePatternConverter and 
> FileLocationPatternConverter seem to output their rendered 
> values directly to the TextWriter passed in.
> 
> A few days ago I posted code that would change the timezone 
> of dates. I implemented that using a pattern converter. I 
> thought that an alternative implementation would be to use a 
> DateTime layout renderer.
> I thought this would ensure that all DateTimes would be in 
> the correct timezone, not just the %date pattern. I don't 
> think this is possible now. It appears that layout renderers 
> are more focused on the rendering of custom objects and not 
> basic types like DateTime and String. Is it possible to make 
> a String  layout renderer that would convert all strings to 
> upper case?
> 
> Thanks,
> Ron 
> 

Reply via email to