Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!goblin3!goblin1!goblin.stu.neva.ru!border1.hitnews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 27 Jan 2013 13:51:57 -0600 From: Leif Roar Moldskred Subject: Re: ultralog: new concept of logging API Newsgroups: comp.lang.java.programmer References: <0cfefb99-94f9-44e0-9b58-926818a9560d@googlegroups.com> <78bfbd4c-a257-44ed-ae03-73ceb19fab18@googlegroups.com> User-Agent: tin/2.0.0-20110823 ("Ardenistiel") (UNIX) (Linux/3.0.0-30-generic-pae (i686)) Message-ID: Date: Sun, 27 Jan 2013 13:51:57 -0600 Lines: 59 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-bAPyAbSHerOLYvRZjlED4lKceX1/Q64JWUW0+myV2Sf58QUHeju3Fhmzaux6CT/vXxwREY6r8KgdpTC!i/+nJ1C3oZnZ6e7g/WSq3g22+sGcey1JWGzN9LvVNWXOHKg8FhkZbLdf34hameIQXO1NsaNI+mpE!ew== X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3058 Xref: csiph.com comp.lang.java.programmer:21805 vladimirow@mail.ru wrote: > For me the following: > > logger.userLoggedIn (userName, address); > > is clearer than > > logger.info ("User `" + userName + "' logged in from " + address); > > or > > logger.info ("User `{}' logged in from {}", userName, address); > > or > > logger.infoT ("User `{}' logged in from {}").p (userName).p (address).endT (); > > Anyway this is matter of personal preference. Actually, I disagree with both claims, but regardless, even if you prefer the first version, I fail to see the advantage in your way of doing it compared to just doing this: public SomeResult someMethod( Argument anArg ) { /* Boring business stuff */ Result aResult = ... /* Exciting logging stuff */ logResultDigest( anArg, aResult ); return aResult; } private void logResultDigest( Argument arg, SomeResult result ) { String orderID = arg.getOrder().getID(); if( yeOldeLogger.isDebugEnabled() ) { String resultDigest = expensiveDigestCalculation( result ); yeOldeLogger.debug( "Processed order {} in process {}. Result digest : {}", orderID, this.processID, resultDigest ); } else { yeOldeLogger.info( "Processed order {} in process {}.", orderID, this.processID ); } } To me, your way of doing it just introduces a pointless extra layer of indirection into the code which provides little actual benefit. In my experience, a particular log message is almost always tied to only one specific point in the code, so it makes no sense to abstract it out into an interface. (I actually think a good argument can be made that writing identical log messages from multiple points in the good is a strong suggestion that either your code is badly structured and should be refactored, or that your logging scheme is badly thought out and uninformative.) -- Leif Roar Moldskred