Return-Path: X-Original-To: apmail-logging-commits-archive@minotaur.apache.org Delivered-To: apmail-logging-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3E9CF10D6F for ; Sun, 5 May 2013 05:12:19 +0000 (UTC) Received: (qmail 41436 invoked by uid 500); 5 May 2013 05:12:18 -0000 Delivered-To: apmail-logging-commits-archive@logging.apache.org Received: (qmail 41353 invoked by uid 500); 5 May 2013 05:12:15 -0000 Mailing-List: contact commits-help@logging.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@logging.apache.org Delivered-To: mailing list commits@logging.apache.org Received: (qmail 41320 invoked by uid 99); 5 May 2013 05:12:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 May 2013 05:12:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 May 2013 05:12:11 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3AC8C23888E4; Sun, 5 May 2013 05:11:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1479236 - in /logging/log4j/log4j2/trunk: core/src/main/java/org/apache/logging/log4j/core/Logger.java log4j12-api/src/test/java/org/apache/log4j/LoggingTest.java log4j12-api/src/test/resources/log4j2-config.xml src/changes/changes.xml Date: Sun, 05 May 2013 05:11:50 -0000 To: commits@logging.apache.org From: rgoers@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130505051150.3AC8C23888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rgoers Date: Sun May 5 05:11:49 2013 New Revision: 1479236 URL: http://svn.apache.org/r1479236 Log: LOG4J2-231 - Logger.getParent() was not returning the correct Logger. Added: logging/log4j/log4j2/trunk/log4j12-api/src/test/java/org/apache/log4j/LoggingTest.java logging/log4j/log4j2/trunk/log4j12-api/src/test/resources/log4j2-config.xml Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java logging/log4j/log4j2/trunk/src/changes/changes.xml Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java?rev=1479236&r1=1479235&r2=1479236&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java (original) +++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/Logger.java Sun May 5 05:11:49 2013 @@ -59,18 +59,20 @@ public class Logger extends AbstractLogg } /** + * This method is only used for 1.x compatibility. * Returns the parent of this Logger. If it doesn't already exist return a temporary Logger. * @return The parent Logger. */ public Logger getParent() { - final LoggerConfig lc = config.loggerConfig.getParent(); + LoggerConfig lc = config.loggerConfig.getName().equals(getName()) ? config.loggerConfig.getParent() : + config.loggerConfig; if (lc == null) { return null; } if (context.hasLogger(lc.getName())) { - return context.getLogger(getName(), getMessageFactory()); + return context.getLogger(lc.getName(), getMessageFactory()); } - return new Logger(context, getName(), this.getMessageFactory()); + return new Logger(context, lc.getName(), this.getMessageFactory()); } /** Added: logging/log4j/log4j2/trunk/log4j12-api/src/test/java/org/apache/log4j/LoggingTest.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j12-api/src/test/java/org/apache/log4j/LoggingTest.java?rev=1479236&view=auto ============================================================================== --- logging/log4j/log4j2/trunk/log4j12-api/src/test/java/org/apache/log4j/LoggingTest.java (added) +++ logging/log4j/log4j2/trunk/log4j12-api/src/test/java/org/apache/log4j/LoggingTest.java Sun May 5 05:11:49 2013 @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.log4j; + +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.Configuration; +import org.apache.logging.log4j.core.config.Configurator; +import org.apache.logging.log4j.status.StatusLogger; +import org.apache.logging.log4j.test.appender.ListAppender; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * + */ +public class LoggingTest { + + private static final String CONFIG = "log4j2-config.xml"; + private static Configuration config; + private static ListAppender app; + private static LoggerContext ctx; + + @BeforeClass + public static void setupClass() { + ctx = Configurator.initialize("Test1", null, CONFIG); + } + + @AfterClass + public static void cleanupClass() { + ctx.stop(); + StatusLogger.getLogger().reset(); + } + + @Before + @SuppressWarnings("unchecked") + public void before() { + config = ctx.getConfiguration(); + } + + @Test + public void testParent() { + final Logger a = Logger.getLogger("org.apache.test.logging.Test"); + Category parent = a.getParent(); + assertNotNull("No parent Logger", parent); + assertTrue("Incorrect parent logger", parent.getName().equals("org.apache.test.logging")); + } + +} Added: logging/log4j/log4j2/trunk/log4j12-api/src/test/resources/log4j2-config.xml URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j12-api/src/test/resources/log4j2-config.xml?rev=1479236&view=auto ============================================================================== --- logging/log4j/log4j2/trunk/log4j12-api/src/test/resources/log4j2-config.xml (added) +++ logging/log4j/log4j2/trunk/log4j12-api/src/test/resources/log4j2-config.xml Sun May 5 05:11:49 2013 @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1479236&r1=1479235&r2=1479236&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/src/changes/changes.xml (original) +++ logging/log4j/log4j2/trunk/src/changes/changes.xml Sun May 5 05:11:49 2013 @@ -23,6 +23,9 @@ + + Logger.getParent() was not returning the correct Logger. + Renamed Plugin annotation attribute from "type" to "category".