Return-Path: X-Original-To: apmail-struts-dev-archive@www.apache.org Delivered-To: apmail-struts-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 78DD011CAF for ; Fri, 16 May 2014 23:12:27 +0000 (UTC) Received: (qmail 13584 invoked by uid 500); 16 May 2014 11:42:10 -0000 Delivered-To: apmail-struts-dev-archive@struts.apache.org Received: (qmail 19216 invoked by uid 500); 16 May 2014 11:24:56 -0000 Mailing-List: contact dev-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Developers List" Reply-To: "Struts Developers List" Delivered-To: mailing list dev@struts.apache.org Received: (qmail 33870 invoked by uid 99); 16 May 2014 11:08:53 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 May 2014 11:08:53 +0000 Received: from localhost (HELO mail-yk0-f173.google.com) (127.0.0.1) (smtp-auth username lukaszlenart, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 May 2014 10:16:20 +0000 Received: by mail-yk0-f173.google.com with SMTP id 142so664851ykq.4 for ; Thu, 15 May 2014 03:16:19 -0700 (PDT) X-Received: by 10.236.117.5 with SMTP id i5mr6999429yhh.19.1400148979611; Thu, 15 May 2014 03:16:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.170.194.130 with HTTP; Thu, 15 May 2014 03:15:58 -0700 (PDT) In-Reply-To: References: From: Lukasz Lenart Date: Thu, 15 May 2014 12:15:58 +0200 Message-ID: Subject: Re: Less boilerplate in code To: Struts Developers List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2014-05-15 3:40 GMT+02:00 Chris Pratt : > Then you still have to use code like: > > if(LOG.isDebugEnabled()) { > LOG.debug("Action name is [#0]",action.getName()); > } > > Any time that the value isn't in an available primitive. With Onyx you > could just write: > > LOG.debug("Action name is {0.name}",action); > > Which is much more readable and just as performant. That's why I want to improve the implementations of XWork's Logger - to get exactly the same gain > Anyone who has an application with SLF4j, plus Log4j and other logging > engines doesn't understand SLF4j. > > SLF4j provides an API for library developers to use (kind of in the old > commons logging vein), where the back end decision can be given to the us= er > of the library, but that's only the top level of SLF4j. The same we have already in XWork logging layer, you're using one Logger API but it depends on user which implementation to use (SLF4j, Log4j, jul) just by dropping in given lib (or using if it's already available). User can also implement its own version without too much hassle. > As I said, SLF4j provides an API, but it also provides conduits to funnel > just about any logging information through a SINGLE logging engine, be th= at > Log4j, java.util.logging, SysOut, Logback or whatever you would like. If > you are using old libraries that haven't adopted SLF4j yet, and are using > Log4j, commons logging or java.util.logging, you can add shims that will > route all the information that was originally intended for that logging > engine (i.e. java.util.logging or commons logging) through SLF4j, to the > chosen logging engine (e.g. Log4j). And, all you have to do to install > most shims is drop the jar file in the libs directory. That way you have > one engine to configure, but you get control over all the logging > information from all the libraries in your system. The problem here is we're going to introduce a new required dependency (SLF4j API) and this can be unacceptable for some companies (don't ask me why, I know it's real). Another thing I just want to use what user already is using and not tell him "add this jar, that jar and configure it via xml" - overcomplicated. Right now Struts will use what is already available on classpath - Log4j, SLF4j, JDK logger - in that order. If user needs to use specific implementation he can simple add -Dxwork.loggerFactory=3Dcom.opensymphony.xwork2.util.logging.slf4j.Slf4jLog= gerFactory and done http://struts.apache.org/release/2.3.x/docs/logging.html > Weather or not you decide to go with my Onyx layer, I would strongly > suggest moving to SLF4j. Still not convinced, too often I saw projects that switched to SLF4j just because (Hibernate) and now there are conflicts with different version of SLF4j required per each product (ie. JBoss and Hibernate) I'd rather adopt your Onyx lib to get power of extended logging capabilitie= s. Regards --=20 =C5=81ukasz + 48 606 323 122 http://www.lenart.org.pl/ --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org For additional commands, e-mail: dev-help@struts.apache.org