Thomas Tuft Muller wrote:
> 
> | Can you please expand? What type of object renderers
> | have you implemented?
> 
> I develop telephony applications based on JTAPI. I have implemented
> different renderers for the core interfaces, like javax.telephony.Call,
> javax.telephony.Connection etc. In this way I can get varying depth of
> information about the different objects implementing the interfaces. As for
> now I have a simple, medium, and extensive renderer for each interface.
> 
> The problem is that I can only register a renderer for a certain class in
> the default hierarchy whereby the renderer becomes 'global'. I would like to
> register a SimpleCallRenderer in category x and an ExtensiveCallRenderer in
> Category y.
> 
> | Why do you need different renderers on a category
> | basis? Can you please explain?
> 
> I think this is an important requirement; for Category X I would like to log
> java.lang.Integer as "Integer: " + Integer.toString( theInt ), and in
> category Y I would like to log it as Integer.toString( theInt ).
> 
> Is it possible?

Nope. You can't do that. An ObjectRenderer renders the same for all
categories.

> 
> I've just a limited understanding of the detail design of Log4j, but I would
> think the granularity of renderers should be the same as for Layouts, that
> is, on a Category basis.

If you need per-category rendering yo may have to write a Layout which
knows about the types of Object you log (Integers in your example), e.g.
a subclass of PatternLayout which recognixes custom conversion
characters related to your logged Objects.

Actually, in your example you can just use PatternLayout without any
extension. Basically the %m ends up being populated by calling toString
on your object (unless you explicitly register an ObjectRenderer for
Integers), so you could have a pattern "Integer: %m%n" on Category X and
"%m%n" on Category Y and the effect should be as you described.

--
Anders Kristensen

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

Reply via email to