[Yanel-dev] Re: [Yanel-commits] rev 45913 - public/yanel/trunk/src/webapp/src/java/org/wyona/yanel/servlet

Guillaume Déflache guillaume.deflache at wyona.com
Wed Dec 9 09:36:06 CET 2009


Michael Wechner schrieb:
> Guillaume Déflache wrote:
[...]
>> As a closing remark, maybe for all kinds of request-related logging 
>> messages (not only 404), we should use consistent and standard formats:
> 
> good points, will try to make some improvements tomorrow
>> maybe using 
>> http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/or/ObjectRenderer.html 
>> would help.
> 
> I am not sure I understand. Can you explain a bit?

According 
<http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Category.html#info(java.lang.Object)>:
> If the category is INFO  enabled, then it converts the message object passed as parameter to a string by invoking the appropriate ObjectRenderer.

In <http://logging.apache.org/log4j/1.2/manual.html> at the end of the 
"Appenders and Layouts" section:
> Just as importantly, log4j will render the content of the log message according to user specified criteria. For example, if you frequently need to log Oranges, an object type used in your current project, then you can register an OrangeRenderer that will be invoked whenever an orange needs to be logged.
> 
> Object rendering follows the class hierarchy. For example, assuming oranges are fruits, if you register an FruitRenderer, all fruits including oranges will be rendered by the FruitRenderer, unless of course you registered an orange specific OrangeRenderer.
> 
> Object renderers have to implement the ObjectRenderer interface.

My point is that we'd better keep all information we collect in 
object-form as long as possible to be able to easily change the output 
format or add more fields (the way log4j does it for the whole log line) 
instead of doing the formatting in many separate places.
So maybe we should have a WebHitRenderer (for pages accessed without 
problems) and/or a WebMissRenderer (for 404s and other errors) or similar.


More information about the Yanel-development mailing list