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/05 16:07:31 UTC

[logging-log4j2] branch release-2.x updated (c47e984 -> ffa606e)

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

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


    from c47e984  Log4j 1.2 bridge adds org.apache.log4j.component.helpers.Constants.
     new 8b6dd63  Log4j 1.2 bridge adds org.apache.log4j.helpers.LogLog.
     new cb4d703  Log4j 1.2 bridge adds org.apache.log4j.helpers.LogLog.
     new ffa606e  Fix indentation.

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:
 .../main/java/org/apache/log4j/helpers/LogLog.java | 173 +++++++++++++++++++++
 src/changes/changes.xml                            |   9 +-
 2 files changed, 179 insertions(+), 3 deletions(-)
 create mode 100644 log4j-1.2-api/src/main/java/org/apache/log4j/helpers/LogLog.java

[logging-log4j2] 01/03: Log4j 1.2 bridge adds org.apache.log4j.helpers.LogLog.

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

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

commit 8b6dd631fae49bf7cd35c489c662e8afe1d2f5f7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 5 11:06:15 2022 -0500

    Log4j 1.2 bridge adds org.apache.log4j.helpers.LogLog.
---
 .../main/java/org/apache/log4j/helpers/LogLog.java | 173 +++++++++++++++++++++
 1 file changed, 173 insertions(+)

diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/LogLog.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/LogLog.java
new file mode 100644
index 0000000..d40773e
--- /dev/null
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/LogLog.java
@@ -0,0 +1,173 @@
+/*
+ * 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.helpers;
+
+import org.apache.logging.log4j.status.StatusLogger;
+
+/**
+ * Logs statements from within Log4j.
+ *
+ * <p>
+ * Log4j components cannot make Log4j logging calls. However, it is sometimes useful for the user to learn about what
+ * Log4j is doing. You can enable Log4j internal logging by defining the <b>log4j.configDebug</b> variable.
+ * </p>
+ * <p>
+ * All Log4j internal debug calls go to <code>System.out</code> where as internal error messages are sent to
+ * <code>System.err</code>. All internal messages are prepended with the string "log4j: ".
+ * </p>
+ *
+ * @since 0.8.2
+ */
+public class LogLog {
+
+    private static final StatusLogger LOGGER = StatusLogger.getLogger();
+
+    /**
+     * Makes Log4j print log4j-internal debug statements to <code>System.out</code>.
+     *
+     * <p>
+     * The value of this string is {@value #DEBUG_KEY}
+     * </p>
+     * <p>
+     * Note that the search for all option names is case sensitive.
+     * </p>
+     */
+    public static final String DEBUG_KEY = "log4j.debug";
+
+    /**
+     * Makes Log4j components print log4j-internal debug statements to <code>System.out</code>.
+     *
+     * <p>
+     * The value of this string is {@value #CONFIG_DEBUG_KEY}.
+     * </p>
+     * <p>
+     * Note that the search for all option names is case sensitive.
+     * </p>
+     *
+     * @deprecated Use {@link #DEBUG_KEY} instead.
+     */
+    @Deprecated
+    public static final String CONFIG_DEBUG_KEY = "log4j.configDebug";
+
+    /**
+     * Debug enabled Enable or disable.
+     */
+    protected static boolean debugEnabled = false;
+
+    /**
+     * In quietMode not even errors generate any output.
+     */
+    private static boolean quietMode = false;
+
+    static {
+        String key = OptionConverter.getSystemProperty(DEBUG_KEY, null);
+        if (key == null) {
+            key = OptionConverter.getSystemProperty(CONFIG_DEBUG_KEY, null);
+        }
+        if (key != null) {
+            debugEnabled = OptionConverter.toBoolean(key, true);
+        }
+    }
+
+    /**
+     * Logs Log4j internal debug statements.
+     * 
+     * @param message the message object to log.
+     */
+    public static void debug(final String message) {
+        if (debugEnabled && !quietMode) {
+            LOGGER.debug(message);
+        }
+    }
+
+    /**
+     * Logs Log4j internal debug statements.
+     * 
+     * @param message the message object to log.
+     * @param throwable the {@code Throwable} to log, including its stack trace.
+     */
+    public static void debug(final String message, final Throwable throwable) {
+        if (debugEnabled && !quietMode) {
+            LOGGER.debug(message, throwable);
+        }
+    }
+
+    /**
+     * Logs Log4j internal error statements.
+     * 
+     * @param message the message object to log.
+     */
+    public static void error(final String message) {
+        if (!quietMode) {
+            LOGGER.error(message);
+        }
+    }
+
+    /**
+     * Logs Log4j internal error statements.
+     * 
+     * @param message the message object to log.
+     * @param throwable the {@code Throwable} to log, including its stack trace.
+     */
+    public static void error(final String message, final Throwable throwable) {
+        if (!quietMode) {
+            LOGGER.error(message, throwable);
+        }
+    }
+
+    /**
+     * Enables and disables Log4j internal logging.
+     *
+     * @param enabled Enable or disable.
+     */
+    static public void setInternalDebugging(final boolean enabled) {
+        debugEnabled = enabled;
+    }
+
+    /**
+     * In quite mode no LogLog generates strictly no output, not even for errors.
+     *
+     * @param quietMode A true for not
+     */
+    public static void setQuietMode(final boolean quietMode) {
+        LogLog.quietMode = quietMode;
+    }
+
+    /**
+     * Logs Log4j internal warning statements.
+     * 
+     * @param message the message object to log.
+     */
+    public static void warn(final String message) {
+        if (!quietMode) {
+            LOGGER.warn(message);
+        }
+    }
+
+    /**
+     * Logs Log4j internal warnings.
+     * 
+     * @param message the message object to log.
+     * @param throwable the {@code Throwable} to log, including its stack trace.
+     */
+    public static void warn(final String message, final Throwable throwable) {
+        if (!quietMode) {
+            LOGGER.warn(message, throwable);
+        }
+    }
+}

[logging-log4j2] 02/03: Log4j 1.2 bridge adds org.apache.log4j.helpers.LogLog.

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

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

commit cb4d7036a74752f524577f66eb5153f5d1e6670f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 5 11:07:12 2022 -0500

    Log4j 1.2 bridge adds org.apache.log4j.helpers.LogLog.
---
 src/changes/changes.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2889fd6..3dde73f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -85,6 +85,9 @@
       <action dev="ggregory" type="fix" issue="LOG4J2-3316">
        Log4j 1.2 bridge adds org.apache.log4j.component.helpers.Constants.
       </action>
+      <action dev="ggregory" type="fix" issue="LOG4J2-3316">
+       Log4j 1.2 bridge adds org.apache.log4j.helpers.LogLog.
+      </action>      
       <!-- ADD -->
       <!-- UPDATES -->
 	</release>

[logging-log4j2] 03/03: Fix indentation.

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

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

commit ffa606e6e3c30f75ac3107f18f6c514aa7d5d28a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 5 11:07:28 2022 -0500

    Fix indentation.
---
 src/changes/changes.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 3dde73f..89199d5 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -77,16 +77,16 @@
         Log4j 1.2 bridge missing class org.apache.log4j.or.RendererMap.
       </action>
       <action dev="ggregory" type="fix" issue="LOG4J2-3281">
-       Log4j 1.2 bridge PropertiesConfiguration.buildAppender not adding filters to custom appender.
+        Log4j 1.2 bridge PropertiesConfiguration.buildAppender not adding filters to custom appender.
       </action>
       <action dev="ggregory" type="fix" issue="LOG4J2-3316">
-       Log4j 1.2 bridge should ignore case in properties file keys.
+        Log4j 1.2 bridge should ignore case in properties file keys.
       </action>
       <action dev="ggregory" type="fix" issue="LOG4J2-3316">
-       Log4j 1.2 bridge adds org.apache.log4j.component.helpers.Constants.
+        Log4j 1.2 bridge adds org.apache.log4j.component.helpers.Constants.
       </action>
       <action dev="ggregory" type="fix" issue="LOG4J2-3316">
-       Log4j 1.2 bridge adds org.apache.log4j.helpers.LogLog.
+        Log4j 1.2 bridge adds org.apache.log4j.helpers.LogLog.
       </action>      
       <!-- ADD -->
       <!-- UPDATES -->