logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: A new thread for log4j 2.0 discussion (Was Re: svn commit: r943816 [1/9] - in /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers: ./ log4j12-api/ log4j12-api/src/ log4j12-api/src/main/ log4j12-api/src/main/java/ log4j12-api/src/main/java/org/ log4j12-api/src/main/java/org/apache/ log4j12-api/sr...)
Date Sat, 22 May 2010 15:50:07 GMT

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: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message