Return-Path: X-Original-To: apmail-maven-dev-archive@www.apache.org Delivered-To: apmail-maven-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 D7285EECE for ; Sun, 17 Mar 2013 20:19:36 +0000 (UTC) Received: (qmail 29553 invoked by uid 500); 17 Mar 2013 20:19:36 -0000 Delivered-To: apmail-maven-dev-archive@maven.apache.org Received: (qmail 29464 invoked by uid 500); 17 Mar 2013 20:19:36 -0000 Mailing-List: contact dev-help@maven.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Maven Developers List" Reply-To: "Maven Developers List" Delivered-To: mailing list dev@maven.apache.org Received: (qmail 29453 invoked by uid 99); 17 Mar 2013 20:19:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Mar 2013 20:19:36 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [66.111.4.25] (HELO out1-smtp.messagingengine.com) (66.111.4.25) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Mar 2013 20:19:30 +0000 Received: from compute5.internal (compute5.nyi.mail.srv.osa [10.202.2.45]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 689F82084D for ; Sun, 17 Mar 2013 16:19:09 -0400 (EDT) Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute5.internal (MEProxy); Sun, 17 Mar 2013 16:19:09 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=tesla.io; h= subject:references:from:content-type:in-reply-to:message-id:date :to:content-transfer-encoding:mime-version; s=mesmtp; bh=YBL5itS atpIZtXE4VTNC9Ymmj+g=; b=vXksKr5Bm1mbnKKQWRvP4Rkeu1DbwA4vydXWWw3 aTKnx4nkNIX8z5cwLAo4t9jLuLtHV6gEgN4mG14fc9gwump1WwBYvE4iuRdyxrUP iwPkEaBbmhd86mKHka7AH/L9CEux0NIJQeov0e7PEg5zf0q08ymlZrSGt4e45oLt cpEw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=subject:references:from:content-type :in-reply-to:message-id:date:to:content-transfer-encoding :mime-version; s=smtpout; bh=YBL5itSatpIZtXE4VTNC9Ymmj+g=; b=Gvg aHDOwMZtAo23in2DwfzfEawvcz3zNcvVh1Jp35kBXDE5raCZr3yBwVMsDzNL9/MM 7fewXIeV8izZLw8GSlkZie21dAc351evX6BtI4Ncv4k8WofzL/1mgoDFYcEOXKdn DgbRlmAkltYnKbuA5STWi8Ut9QRdA81p+adVAFI4= X-Sasl-enc: 4aDVwA2SHJmbQPyouc2ZEtxoggv8eld+xxOwUPsqY5Ad 1363551548 Received: from [10.73.143.220] (unknown [32.166.82.50]) by mail.messagingengine.com (Postfix) with ESMTPA id B2EA2201006 for ; Sun, 17 Mar 2013 16:19:08 -0400 (EDT) Subject: Re: Logger and Embedded Maven Core ITs References: <63F412AC-36B2-45E2-B771-42A2E454D151@tesla.io> <51462332.2030409@qos.ch> From: Jason van Zyl Content-Type: text/plain; charset=utf-8 X-Mailer: iPhone Mail (10A523) In-Reply-To: <51462332.2030409@qos.ch> Message-Id: <129B8FB6-FAB3-4B93-B3EB-905E5D4306BC@tesla.io> Date: Sun, 17 Mar 2013 13:19:04 -0700 To: Maven Developers List Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) X-Virus-Checked: Checked by ClamAV on apache.org Thanks! We can try it with the helper we currently have. jvz On 2013-03-17, at 1:10 PM, ceki wrote: >=20 >=20 > On 17.03.2013 00:47, Jason van Zyl wrote: >> If that's the case Ceki might be able to add the clearing of the logger m= ap to the reset method. >>=20 >> Ceki, would this be hard to change? >=20 > I just added a reset method to SimpleLoggerFactory. See https://github.com= /qos-ch/slf4j/commit/6dd3a60ee77a5cd17e for the commit. Here is sample code= for invoking this method in Maven tests: >=20 > import org.slf4j.ILoggerFactory; > import org.slf4j.LoggerFactory; >=20 > ILoggerFactory iLoggerFactory =3D LoggerFactory.getILoggerFactory(); > if(iLoggerFactory instanceof SimpleLoggerFactory) { > ((SimpleLoggerFactory) iLoggerFactory).reset(); > } >=20 > As the reset() method is package protected, it needs to be invoked from co= de in the org.slf4j.impl package. A "friend" class could expose the reset me= thod to classes in other packages. >=20 > Anyway, let me know how if this works for you. >=20 >> On Mar 16, 2013, at 4:38 PM, Stuart McCulloch wrote: >>=20 >>> On 16 Mar 2013, at 13:58, Jason van Zyl wrote: >>>=20 >>>> Herv=C3=A9, >>>>=20 >>>> Can you take a look at the logging changes you made to try and use the S= LF4J package private method for resetting the logger? The streams are being r= eset correctly but the logging level doesn't appear to be reset which causes= the embedded ITs to fail. >>>=20 >>> Did some investigating and the issue seems to be that SLF4J Simple uses a= static singleton logger factory which contains a map of cached loggers. >>>=20 >>> Because embedded test mode uses the same classloader for all the tests (= it only forks once at the start) each test therefore sees the same logger fa= ctory and any previously cached loggers. >>>=20 >>> This means that although the MavenCLI successfully resets SLF4J to refre= sh the log level, the new setting doesn't affect previously cached loggers (= they only pick up the level in their constructor). >>>=20 >>> This can be shown with the following hack to clear the logger map (not s= ane code, just proof-of-concept) which solves the embedded logging IT failur= es: >>>=20 >>> diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/logging/i= mpl/Slf4jSimpleConfiguration.java b/maven-embedder/src/main/java/org/apache/= maven/cli/logging/impl/Slf4jSimpleConfiguration.java >>> index 6a7f385..f1af143 100644 >>> --- a/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf= 4jSimpleConfiguration.java >>> +++ b/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf= 4jSimpleConfiguration.java >>> @@ -58,5 +58,20 @@ public void activate() >>> // property for root logger level or System.out redirection need= to be taken into account >>> MavenSlf4jFriend.reset(); >>> MavenSlf4jSimpleFriend.init(); >>> + >>> + try >>> + { >>> + org.slf4j.ILoggerFactory loggerFactory =3D org.slf4j.Logge= rFactory.getILoggerFactory(); >>> + synchronized ( loggerFactory ) >>> + { >>> + java.lang.reflect.Field loggerMap =3D loggerFactory.ge= tClass().getDeclaredField( "loggerMap" ); >>> + loggerMap.setAccessible( true ); >>> + ( (java.util.Map) loggerMap.get( loggerFactory ) ).cle= ar(); >>> + } >>> + } >>> + catch ( Exception e ) >>> + { >>> + // ignore for now... >>> + } >>> } >>> } >>>=20 >>>> Thanks, >>>>=20 >>>> Jason >>>>=20 >>>> ---------------------------------------------------------- >>>> Jason van Zyl >>>> Founder & CTO, Sonatype >>>> Founder, Apache Maven >>>> http://twitter.com/jvanzyl >>>> --------------------------------------------------------- >>>>=20 >>>> People develop abstractions by generalizing from concrete examples. >>>> Every attempt to determine the correct abstraction on paper without >>>> actually developing a running system is doomed to failure. No one >>>> is that smart. A framework is a resuable design, so you develop it by >>>> looking at the things it is supposed to be a design of. The more exampl= es >>>> you look at, the more general your framework will be. >>>>=20 >>>> -- Ralph Johnson & Don Roberts, Patterns for Evolving Frameworks >>>=20 >>>=20 >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org >>> For additional commands, e-mail: dev-help@maven.apache.org >>=20 >> Thanks, >>=20 >> Jason >=20 > -- > Ceki >=20 >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org > For additional commands, e-mail: dev-help@maven.apache.org >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For additional commands, e-mail: dev-help@maven.apache.org