Return-Path: X-Original-To: apmail-logging-log4j-dev-archive@www.apache.org Delivered-To: apmail-logging-log4j-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 B62EE17541 for ; Fri, 30 Oct 2015 00:15:28 +0000 (UTC) Received: (qmail 6972 invoked by uid 500); 30 Oct 2015 00:15:28 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 6925 invoked by uid 500); 30 Oct 2015 00:15:28 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 6915 invoked by uid 99); 30 Oct 2015 00:15:28 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Oct 2015 00:15:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 13DDFC0EBE for ; Fri, 30 Oct 2015 00:15:28 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.001 X-Spam-Level: *** X-Spam-Status: No, score=3.001 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=3, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id FrL6RIUyXS1t for ; Fri, 30 Oct 2015 00:15:15 +0000 (UTC) Received: from smtp679.redcondor.net (smtp679.redcondor.net [208.80.206.79]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id B9B9520927 for ; Fri, 30 Oct 2015 00:15:14 +0000 (UTC) Received: from mailproxy11.neonova.net ([137.118.22.76]) by smtp679.redcondor.net ({61e46e34-cfba-43f0-8a4f-f3a481f7eb08}) via TCP (outbound) with ESMTP id 20151030001504228_0679 for ; Fri, 30 Oct 2015 00:15:04 +0000 X-RC-FROM: X-RC-RCPT: Received: from [192.168.1.14] (ip72-201-43-179.ph.ph.cox.net [72.201.43.179]) (Authenticated sender: ralph.goers@dslextreme.com) by mailproxy11.neonova.net (Postfix) with ESMTPA id 0E2D1360072 for ; Thu, 29 Oct 2015 20:14:59 -0400 (EDT) From: Ralph Goers Content-Type: multipart/alternative; boundary="Apple-Mail=_CF86D434-F2CB-4521-9F93-C776BB4DEB72" Message-Id: <57C72CF7-E1FF-4432-8638-66309E025E5D@dslextreme.com> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: Programmatically Modifying the Current Configuration after Initialization Date: Thu, 29 Oct 2015 17:15:00 -0700 References: To: Log4J Developers List In-Reply-To: X-Mailer: Apple Mail (2.2104) X-MAG-OUTBOUND: greymail.redcondor.net@137.118.22.64/27 --Apple-Mail=_CF86D434-F2CB-4521-9F93-C776BB4DEB72 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 I imagine that we added more parameters to some of the methods since it = was first published.=20 What do you mean by "it doesn=E2=80=99t work=E2=80=9D? Are you getting = an exception? Since no Loggers were modified to point to your new = appender I am thinking all it is going to do is create an empty file. = This seems like a follow-on to our discussion in the Jira issue about = the PrintStream where you were doing the same thing. Ralph > On Oct 29, 2015, at 4:58 PM, Gary Gregory = wrote: >=20 > Our nice example "Programmatically Modifying the Current Configuration = after Initialization" does not work. (The PatternLayout.create() call = does not compile too). >=20 > I've simplified it to: >=20 > @Test > public void test() { > final LoggerContext ctx =3D (LoggerContext) = LogManager.getContext(false); > final Configuration config =3D ctx.getConfiguration(); > Layout layout =3D PatternLayout.createDefaultLayout(); > Appender appender =3D = FileAppender.createAppender("target/test.log", "false", "false", "File", = "true", "false", > "false", "4000", layout, null, "false", null, config); > appender.start(); > config.addAppender(appender); > ctx.updateLoggers(); > LogManager.getLogger().error("FOO MSG"); > } >=20 > and it creates an empty file. >=20 > What am I missing? The test class has nothing else in it. >=20 > Gary >=20 > --=20 > E-Mail: garydgregory@gmail.com | = ggregory@apache.org > Java Persistence with Hibernate, Second Edition = > JUnit in Action, Second Edition > Spring Batch in Action > Blog: http://garygregory.wordpress.com = =20 > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory --Apple-Mail=_CF86D434-F2CB-4521-9F93-C776BB4DEB72 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
I imagine that we added more parameters to = some of the methods since it was first published. 

What do you mean by "it = doesn=E2=80=99t work=E2=80=9D? Are you getting an exception?  Since = no Loggers were modified to point to your new appender I am thinking all = it is going to do is create an empty file. This seems like a follow-on = to our discussion in the Jira issue about the PrintStream where you were = doing the same thing.

Ralph

On Oct 29, 2015, at 4:58 PM, Gary Gregory = <garydgregory@gmail.com> wrote:

Our nice example "Programmatically Modifying the Current = Configuration after Initialization" does not work. = (The PatternLayout.create() call does not compile too).

I've simplified it = to:

    @Test
    public = void test() {
        final = LoggerContext ctx =3D (LoggerContext) = LogManager.getContext(false);
      =   final Configuration config =3D ctx.getConfiguration();
        Layout<?> layout =3D = PatternLayout.createDefaultLayout();
    =     Appender appender =3D = FileAppender.createAppender("target/test.log", "false", "false", "File", = "true", "false",
          =       "false", "4000", layout, null, "false", null, = config);
        = appender.start();
        = config.addAppender(appender);
      =   ctx.updateLoggers();
      =   LogManager.getLogger().error("FOO MSG");
    }

and it creates an empty file.

What am I missing? The test class has = nothing else in it.

Gary

--

= --Apple-Mail=_CF86D434-F2CB-4521-9F93-C776BB4DEB72--