On May 22, 2010, at 12:46 AM, Thorbjørn Ravn Andersen wrote:

> Den 22/05/10 04.44, Curt Arnold skrev:
>> 
>>> 1. I first created an API that had the features I was looking for. That is 
>>> in log4j2-api. While it supports logging a String or an Object it really 
>>> uses a Message interface which is valuable as it allows users to log 
>>> self-describing objects in a convenient manner.
>>>     
>> My thinking was the message interface would end up so minimal that might as 
>> well just use Object.
>>   
> Would it be feasible to use Object so any object can be logged, but support 
> one or more interfaces that allow a given object to provide more information 
> to the logger framework?

Take a look at the API. Specifically, Logger and AbstractLogger.  debug(Object) 
is supported. Under the covers it turns into log(new ObjectMessage(object)). 
The advantage is if the Object implements the Message interface then the call 
is debug(Message) and the Object is thus self describing. Alternatively, the 
user could associate their object's with Message objects (i.e. 
debug(object.getMessage()). For example, if the Object contains data that 
shouldn't be logged (like a Social Security Number, PIN, etc.) this allows the 
Object the flexibility to control that.

> 
> Also, I have had an issue where the I wanted the toString() method on the 
> object to be logged to be delayed as much as possible (somewhat helped with 
> the {}-construct in slf4j).  This might be doable with a specific log 
> interface.

That is exactly what Message does.

Ralph


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to