You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2022/01/07 15:50:24 UTC

[logging-log4j2] branch master updated (680daf2 -> 800ec09)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git.


    from 680daf2  Log4j 1.2 bridge fixes to structure and behave like 1.2.17.
     new 3d94008  Log4j 1.2 bridge adds org.apache.log4j.spi.NOPLoggerRepository and NOPLogger.
     new 0610594  Log4j 1.2 bridge methods Category.getChainedPriority() and getEffectiveLevel() should not be final.
     new 800ec09  Log4j 1.2 bridge methods Category.getChainedPriority() and getEffectiveLevel() should not be final.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/java/org/apache/log4j/Category.java   |   4 +-
 .../main/java/org/apache/log4j/spi/NOPLogger.java  | 268 +++++++++++++++++++++
 .../org/apache/log4j/spi/NOPLoggerRepository.java  | 154 ++++++++++++
 src/changes/changes.xml                            |   6 +
 4 files changed, 430 insertions(+), 2 deletions(-)
 create mode 100644 log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLogger.java
 create mode 100644 log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLoggerRepository.java

[logging-log4j2] 01/03: Log4j 1.2 bridge adds org.apache.log4j.spi.NOPLoggerRepository and NOPLogger.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 3d94008bdf8e90ba3eb5438848cab28902ecab43
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jan 7 10:45:29 2022 -0500

    Log4j 1.2 bridge adds org.apache.log4j.spi.NOPLoggerRepository and
    NOPLogger.
---
 .../main/java/org/apache/log4j/spi/NOPLogger.java  | 268 +++++++++++++++++++++
 .../org/apache/log4j/spi/NOPLoggerRepository.java  | 154 ++++++++++++
 2 files changed, 422 insertions(+)

diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLogger.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLogger.java
new file mode 100644
index 0000000..0c61358
--- /dev/null
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLogger.java
@@ -0,0 +1,268 @@
+/*
+ * 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.spi;
+
+import java.util.Enumeration;
+import java.util.ResourceBundle;
+import java.util.Vector;
+
+import org.apache.log4j.Appender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+
+/**
+ * No-operation implementation of Logger used by NOPLoggerRepository.
+ *
+ * @since 1.2.15
+ */
+public final class NOPLogger extends Logger {
+
+    /**
+     * Create instance of Logger.
+     *
+     * @param repo repository, may not be null.
+     * @param name name, may not be null, use "root" for root logger.
+     */
+    public NOPLogger(final NOPLoggerRepository repo, final String name) {
+        super(name);
+        this.repository = repo;
+        this.level = Level.OFF;
+        this.parent = this;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void addAppender(final Appender newAppender) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void assertLog(final boolean assertion, final String msg) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void callAppenders(final LoggingEvent event) {
+        // NOP
+    }
+
+    void closeNestedAppenders() {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void debug(final Object message) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void debug(final Object message, final Throwable t) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void error(final Object message) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void error(final Object message, final Throwable t) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void fatal(final Object message) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void fatal(final Object message, final Throwable t) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Enumeration getAllAppenders() {
+        return new Vector<>().elements();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Appender getAppender(final String name) {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Priority getChainedPriority() {
+        return getEffectiveLevel();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Level getEffectiveLevel() {
+        return Level.OFF;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public ResourceBundle getResourceBundle() {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void info(final Object message) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void info(final Object message, final Throwable t) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isAttached(final Appender appender) {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isDebugEnabled() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isEnabledFor(final Priority level) {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isInfoEnabled() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean isTraceEnabled() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void l7dlog(final Priority priority, final String key, final Object[] params, final Throwable t) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void l7dlog(final Priority priority, final String key, final Throwable t) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void log(final Priority priority, final Object message) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void log(final Priority priority, final Object message, final Throwable t) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void log(final String callerFQCN, final Priority level, final Object message, final Throwable t) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void removeAllAppenders() {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void removeAppender(final Appender appender) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void removeAppender(final String name) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void setLevel(final Level level) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void setPriority(final Priority priority) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void setResourceBundle(final ResourceBundle bundle) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void trace(final Object message) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void trace(final Object message, final Throwable t) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void warn(final Object message) {
+        // NOP
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void warn(final Object message, final Throwable t) {
+        // NOP
+    }
+
+}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLoggerRepository.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLoggerRepository.java
new file mode 100644
index 0000000..f64996e
--- /dev/null
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLoggerRepository.java
@@ -0,0 +1,154 @@
+/*
+ * 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.spi;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+import org.apache.log4j.Appender;
+import org.apache.log4j.Category;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+/**
+ * No-operation implementation of LoggerRepository which is used when LogManager.repositorySelector is erroneously
+ * nulled during class reloading.
+ *
+ * @since 1.2.15
+ */
+public final class NOPLoggerRepository implements LoggerRepository {
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addHierarchyEventListener(final HierarchyEventListener listener) {
+        // NOP
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void emitNoAppenderWarning(final Category cat) {
+        // NOP
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Logger exists(final String name) {
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void fireAddAppenderEvent(final Category logger, final Appender appender) {
+        // NOP
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Enumeration getCurrentCategories() {
+        return getCurrentLoggers();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Enumeration getCurrentLoggers() {
+        return new Vector<>().elements();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Logger getLogger(final String name) {
+        return new NOPLogger(this, name);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Logger getLogger(final String name, final LoggerFactory factory) {
+        return new NOPLogger(this, name);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Logger getRootLogger() {
+        return new NOPLogger(this, "root");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Level getThreshold() {
+        return Level.OFF;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isDisabled(final int level) {
+        return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void resetConfiguration() {
+        // NOP
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setThreshold(final Level level) {
+        // NOP
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setThreshold(final String val) {
+        // NOP
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void shutdown() {
+        // NOP
+    }
+}

[logging-log4j2] 02/03: Log4j 1.2 bridge methods Category.getChainedPriority() and getEffectiveLevel() should not be final.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 06105948e9c6146c174aed02dc14df874e753e1e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jan 7 10:37:14 2022 -0500

    Log4j 1.2 bridge methods Category.getChainedPriority() and
    getEffectiveLevel() should not be final.
---
 log4j-1.2-api/src/main/java/org/apache/log4j/Category.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java b/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
index f359d02..3dc4ff7 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/Category.java
@@ -235,7 +235,7 @@ public class Category implements AppenderAttachable {
         return LogManager.getLoggerRepository();
     }
 
-    public final Level getEffectiveLevel() {
+    public Level getEffectiveLevel() {
         switch (logger.getLevel().getStandardLevel()) {
         case ALL:
             return Level.ALL;
@@ -277,7 +277,7 @@ public class Category implements AppenderAttachable {
         return repository;
     }
 
-    public final Priority getChainedPriority() {
+    public Priority getChainedPriority() {
         return getEffectiveLevel();
     }
 

[logging-log4j2] 03/03: Log4j 1.2 bridge methods Category.getChainedPriority() and getEffectiveLevel() should not be final.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 800ec09da82d957b5721f52defb98eccad2154dd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jan 7 10:50:21 2022 -0500

    Log4j 1.2 bridge methods Category.getChainedPriority() and
    getEffectiveLevel() should not be final.
    
    Log4j 1.2 bridge adds org.apache.log4j.spi.NOPLoggerRepository and
    NOPLogger.
---
 src/changes/changes.xml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 804a99d..e7cd8a7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -242,6 +242,12 @@
       <action dev="ggregory" type="fix">
         Log4j 1.2 bridge adds org.apache.log4j.Hierarchy.
       </action>
+      <action dev="ggregory" type="fix">
+        Log4j 1.2 bridge methods Category.getChainedPriority() and getEffectiveLevel() should not be final.
+      </action>
+      <action dev="ggregory" type="fix">
+        Log4j 1.2 bridge adds org.apache.log4j.spi.NOPLoggerRepository and NOPLogger.
+      </action>
     </release>
     <release version="2.17.1" date="2021-MM-DD" description="GA Release 2.17.1">
       <action issue="LOG4J2-3292" dev="ckozak" type="fix">