Return-Path: X-Original-To: apmail-logging-log4j-user-archive@www.apache.org Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8547111937 for ; Wed, 3 Sep 2014 00:02:16 +0000 (UTC) Received: (qmail 3307 invoked by uid 500); 3 Sep 2014 00:02:16 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 3263 invoked by uid 500); 3 Sep 2014 00:02:15 -0000 Mailing-List: contact log4j-user-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Users List" Reply-To: "Log4J Users List" Delivered-To: mailing list log4j-user@logging.apache.org Received: (qmail 3252 invoked by uid 99); 3 Sep 2014 00:02:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Sep 2014 00:02:15 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of boards@gmail.com designates 209.85.218.42 as permitted sender) Received: from [209.85.218.42] (HELO mail-oi0-f42.google.com) (209.85.218.42) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Sep 2014 00:01:49 +0000 Received: by mail-oi0-f42.google.com with SMTP id v63so4977600oia.15 for ; Tue, 02 Sep 2014 17:01:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=HU64xE7NYVtZNVbHZ6t3873KHrYx5ug7FS8wwO5VdWU=; b=kbBG6QJBos5c5uegYjcFvL0Qt4Pe2w7ful34eslfg44zoko9AcZkf53Nfup/qXQ9dh t1YUp5dL0Kxh+t9B2d+5+LLX699afEtEyzIvaihmtTNRGFiQcbNTOMwqyofPfYlmCGiI mSfDG94RqQEHdeyW2YnsJmOAryyhwQn2q5IBxtac20aQxDZp+hDImqF6xsi+deZddZSP 4mc4VLR9T5QEEVva/vUwnwxnxv3BsYwj5BaVHVHxUUba8JMY6vU5rniZ86SDbPwEOpUJ 0xzk0Py0NWyqdy2ce8NxOHpT68Au/hQVOw3GkB50zuoDgu/Isim0GSdgdNNKpqWrxsrw 4qUA== MIME-Version: 1.0 X-Received: by 10.182.231.170 with SMTP id th10mr34467259obc.8.1409702507643; Tue, 02 Sep 2014 17:01:47 -0700 (PDT) Received: by 10.76.175.103 with HTTP; Tue, 2 Sep 2014 17:01:47 -0700 (PDT) In-Reply-To: References: <05D82BA5-846E-45D8-9256-CF06C01D2B46@gmail.com> Date: Tue, 2 Sep 2014 19:01:47 -0500 Message-ID: Subject: Re: Log4j2 with SL4J Adapter From: Matt Sicker To: Log4J Users List Content-Type: multipart/alternative; boundary=001a11c2eb9c35394705021df18b X-Virus-Checked: Checked by ClamAV on apache.org --001a11c2eb9c35394705021df18b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable If you prefer using GitHub, you can file a pull request instead of a patch file. I still want to test out the functionality, but it should work just fine. On 2 September 2014 09:29, Yogesh Rao wrote: > Hi, > > Just an update on this... i had little time last week to work on this > issue. I am looking into this now and checking if a sandbox can be create= d > for execution of the test cases using class loaders. > > Thank you! > > Regards, > -Yogesh > > > On Mon, Aug 25, 2014 at 10:48 AM, Yogesh Rao wrote: > > > Sure Remko! Will try for it. > > > > Thank you! > > > > Regards, > > -Yogesh > > > > On Monday, August 25, 2014, Remko Popma wrote: > > > >> Great, thank you! I'll have limited PC access the next ten days or so. > >> If you want to take a stab at providing a patch that includes both a > JUnit > >> test and a fix, go for it! > >> > >> > >> On Sun, Aug 24, 2014 at 11:31 PM, Yogesh Rao wrote: > >> > >> > Defect logged under LOG4J2-796 > >> > > >> > Regards, > >> > -Yogesh > >> > > >> > > >> > On Sun, Aug 24, 2014 at 2:41 PM, Remko Popma > >> > wrote: > >> > > >> > > Yogesh, > >> > > > >> > > Thanks! Both would be really helpful! > >> > > > >> > > Remko > >> > > > >> > > Sent from my iPhone > >> > > > >> > > > On 2014/08/24, at 9:09, Yogesh Rao wrote: > >> > > > > >> > > > Thanks Remko! > >> > > > > >> > > > would you like me to create a JIRA ticket for the same ? I could > >> also > >> > try > >> > > > giving a shot at creating that unit test case for you.. > >> > > > > >> > > > Regards, > >> > > > -Yogesh > >> > > > > >> > > > > >> > > >> On Sun, Aug 24, 2014 at 12:35 PM, Remko Popma < > >> remko.popma@gmail.com> > >> > > wrote: > >> > > >> > >> > > >> This looks like a bug. The output is the FQCN (fully qualified > >> name of > >> > > the > >> > > >> logger). > >> > > >> This is probably introduced by the changes made for LOG4J2-555. > >> > > >> > >> > > >> Our unit tests are not picking this up because they use > >> > > >> the ch.qos.logback.classic.Logger, which is a LocationAwareLogg= er > >> and > >> > > >> follows a different code path. > >> > > >> I suspect that Simple Logger is not LocationAware. > >> > > >> > >> > > >> I suspect we should change (in SLF4JLogger.logMessage) > >> > > >> logger.debug(fqcn, getMarker(marker), > >> > message.getFormattedMessage(), > >> > > >> message.getParameters(), t); > >> > > >> to > >> > > >> logger.debug(getMarker(marker), > message.getFormattedMessage(), > >> > > >> message.getParameters(), t); > >> > > >> > >> > > >> I can change this but want to make a failing unit test first an= d > I > >> > > haven't > >> > > >> had time to figure out how to do that yet. > >> > > >> > >> > > >> > >> > > >> > >> > > >>> On Sun, Aug 24, 2014 at 12:00 PM, Yogesh Rao > >> > wrote: > >> > > >>> > >> > > >>> Hi Ralph, > >> > > >>> > >> > > >>> The issue for me is log4j2 to slf4j adaptor doesnt seem to be > >> > working. > >> > > I > >> > > >>> added the log4j configuration only when the logger wasnt worki= ng > >> > hence > >> > > i > >> > > >>> mentioned in brackets that i wasnt sure if its needed or not.. > >> > > >>> > >> > > >>> So since you mentioned that things should be working without t= he > >> > > >>> configuration i removed it and ran but it still doesnt log the > >> > details > >> > > as > >> > > >>> desired. > >> > > >>> > >> > > >>> Is this an issue with log4j2? > >> > > >>> > >> > > >>> Regards, > >> > > >>> -Yogesh > >> > > >>> > >> > > >>> On Sunday, August 24, 2014, Ralph Goers < > >> ralph.goers@dslextreme.com> > >> > > >>> wrote: > >> > > >>> > >> > > >>>> I am really not clear on what the issue is. It seems you have > >> things > >> > > >>>> configured so that you can write to the Log4j 2 API but > actually > >> use > >> > > >>> SLF4J > >> > > >>>> for logging. There is nothing wrong with that but if you are > >> > routing > >> > > >> to > >> > > >>>> SLF4J and using SLF4J Simple Logger then the Log4j 2 > >> configuration > >> > > >> won=E2=80=99t > >> > > >>>> even be used. > >> > > >>>> > >> > > >>>> What are you really wanting to do and what are you expecting = to > >> > > happen? > >> > > >>>> > >> > > >>>> Ralph > >> > > >>>> > >> > > >>>> On Aug 22, 2014, at 7:57 PM, Yogesh Rao >> > > >>> > > >> > > >>>> wrote: > >> > > >>>> > >> > > >>>>> Thanks matt! > >> > > >>>>> > >> > > >>>>> First is what i am attempting to check.. Here instead of > >> logback i > >> > > >> have > >> > > >>>>> used slf4j-simple. > >> > > >>>>> > >> > > >>>>> Based on this is there any issue with my implementation? > >> > > >>>>> > >> > > >>>>> Regards, > >> > > >>>>> -Yogesh > >> > > >>>>> > >> > > >>>>> On Friday, August 22, 2014, Matt Sicker >> > > >>> > > >> > > >>>> wrote: > >> > > >>>>> > >> > > >>>>>> Using log4j-to-slf4j is for when you want to use log4j-api > but > >> > with > >> > > >> an > >> > > >>>>>> slf4j implementation (like logback). log4j-slf4j-impl would > >> allow > >> > > >> you > >> > > >>> to > >> > > >>>>>> use slf4j-api and have that log to log4j-core. > >> > > >>>>>> > >> > > >>>>>> > >> > > >>>>>> On 22 August 2014 08:27, Yogesh Rao >> > > >> > >> > > >>>> > > >> > > >>>>>> wrote: > >> > > >>>>>> > >> > > >>>>>>> Hi, > >> > > >>>>>>> > >> > > >>>>>>> I am trying out the API side of log4j2 with the SLF4J > adaptor. > >> > With > >> > > >>> the > >> > > >>>>>>> sample code written i couldn't see the logging being done > >> > properly. > >> > > >>>>>> Perhaps > >> > > >>>>>>> i am doing something wrong here. > >> > > >>>>>>> > >> > > >>>>>>> Firstly versions of the software are :- > >> > > >>>>>>> > >> > > >>>>>>> 1. JDK 1.8.x > >> > > >>>>>>> 2. Log4j2 (2.0.1) > >> > > >>>>>>> 3. SLF4J 1.7.7 > >> > > >>>>>>> 4. SLF4J's Simple Logger (1.7.7) > >> > > >>>>>>> > >> > > >>>>>>> Code written is as under > >> > > >>>>>>> > >> > > >>>>>>> HelloWorld.java > >> > > >>>>>>> -------------- > >> > > >>>>>>> > >> > > >>>>>>> import org.apache.logging.log4j.LogManager; > >> > > >>>>>>> import org.apache.logging.log4j.Logger; > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> public class HelloWorld { > >> > > >>>>>>> > >> > > >>>>>>> private static final Logger logger =3D > >> > > >>>> LogManager.getLogger("HelloWorld"); > >> > > >>>>>>> public static void main(String[] args) { > >> > > >>>>>>> logger.error("Hello, World!"); > >> > > >>>>>>> logger.error("Logging in user {} with birthday {}", > >> "Ted", > >> > > >>>>>>> "1/10/1900"); > >> > > >>>>>>> } > >> > > >>>>>>> > >> > > >>>>>>> } > >> > > >>>>>>> > >> > > >>>>>>> Log4j.xml (Not sure if this is needed or not) > >> > > >>>>>>> ------------- > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> >> > > >>> %logger{36} > >> > > >>>>>> - > >> > > >>>>>>> %msg%n"/> > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> The output generated is > >> > > >>>>>>> ----------------------------- > >> > > >>>>>>> [main] ERROR HelloWorld - > >> > > >> org.apache.logging.log4j.spi.AbstractLogger > >> > > >>>>>>> [main] ERROR HelloWorld - > >> > > >> org.apache.logging.log4j.spi.AbstractLogger > >> > > >>>>>>> > >> > > >>>>>>> Jars in classpath > >> > > >>>>>>> ---------------------- > >> > > >>>>>>> log4j-api-2.0.1.jar > >> > > >>>>>>> log4j-to-slf4j-2.0.1.jar > >> > > >>>>>>> slf4j-api-1.7.7 > >> > > >>>>>>> slf4j-simple-1.7.7 > >> > > >>>>>>> > >> > > >>>>>>> > >> > > >>>>>>> Also the code works fine if i remove the slf4j related jar= s > >> and > >> > > >>> replace > >> > > >>>>>> it > >> > > >>>>>>> with log4j core. > >> > > >>>>>>> > >> > > >>>>>>> Is there any configuration that i have missed ? > >> > > >>>>>>> > >> > > >>>>>>> Thank You! > >> > > >>>>>>> > >> > > >>>>>>> Regards, > >> > > >>>>>>> -Yogesh > >> > > >>>>>> > >> > > >>>>>> > >> > > >>>>>> > >> > > >>>>>> -- > >> > > >>>>>> Matt Sicker = > > >> > > >>>> > >> > > >>>> > >> > > >>>> > >> > --------------------------------------------------------------------= - > >> > > >>>> To unsubscribe, e-mail: > >> log4j-user-unsubscribe@logging.apache.org > >> > > >>>> > >> > > >>>> For additional commands, e-mail: > >> log4j-user-help@logging.apache.org > >> > > >>>> > >> > > >> > >> > > > >> > > > --------------------------------------------------------------------- > >> > > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org > >> > > For additional commands, e-mail: log4j-user-help@logging.apache.or= g > >> > > > >> > > > >> > > >> > > > --=20 Matt Sicker --001a11c2eb9c35394705021df18b--