[logback-user] Custom Logger for logging custom object?

Adam Brightwell abrightwell at LCE.com
Mon Jul 9 14:43:49 CEST 2012

Hey Andrzej,

Thanks for the suggestion.  I agree that this would be a straight forward solution.  Unfortunately, overriding the toString() method will not work as the format of the log message must be configurable.  Much in the same way that you can configure the format of a log message using the PatternLayout.  For obvious reasons, I believe the format and the message data should be independent of each other.  Thanks again, I appreciate the quick response.


From: Andrzej Zadorozny <andrzej.zadorozny at gmail.com<mailto:andrzej.zadorozny at gmail.com>>
Date: Friday, July 6, 2012 10:20 PM
To: Adam Brightwell <abrightwell at lce.com<mailto:abrightwell at lce.com>>
Subject: Re: [logback-user] Custom Logger for logging custom object?

Hi Adam,

If you could have the POJOs implement their own toString() method (if it's possible in your situation), I think that would be a straight forward solution.

CheerZ! :)

On Fri, Jul 6, 2012 at 7:15 PM, Adam Brightwell <abrightwell at lce.com<mailto:abrightwell at lce.com>> wrote:
Hey All,

I have an interesting logging requirement in front of me.  I am required to log application specific information that is contained within a custom POJO.  The developers will create and fill these POJO's with the appropriate information when a logging "event" takes place.  The hope was that it could then be passed off to our logging system and it would know what to do with it.  However, the obvious problem is that Logger can't be overridden to allow the overloading of the info, warn, error, etc. methods to receive the custom POJO.  I have considered simply implementing the "Delegation Pattern" implementing the slf4j Logger interface and wrapping the logback Logger which would allow me to simply overload the necessary methods.  I was curious what the communities thoughts might be on this potential solution.  Are there other recommendations that might work better for my purposes?  Any help, recommendations or guidance would be greatly appreciated.


Logback-user mailing list
Logback-user at qos.ch<mailto:Logback-user at qos.ch>

Andrzej Zadorozny

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120709/30324bce/attachment.html>

More information about the Logback-user mailing list