You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2022/08/26 15:35:48 UTC

[GitHub] [logging-log4j2] terrettaz opened a new pull request, #1022: SLF4J2

terrettaz opened a new pull request, #1022:
URL: https://github.com/apache/logging-log4j2/pull/1022

     - Bump SLF4J 2.0.0
     - Avoid error reported in [LOG4J2-3139](https://issues.apache.org/jira/browse/LOG4J2-3139)
     - Fix test about [SLF4J-421](https://jira.qos.ch/browse/SLF4J-421)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] ppkarwasz commented on pull request #1022: SLF4J2

Posted by GitBox <gi...@apache.org>.
ppkarwasz commented on PR #1022:
URL: https://github.com/apache/logging-log4j2/pull/1022#issuecomment-1230618566

   @terrettaz, if the rest of the team agrees, we'll merge #1025 instead (which contains your initial contribution and my remarks), so no need to improve this PR.
   
   Thank you for your contribution.
   
   Taking account of the recent changes the `log4j-slf4j20-impl` bridge is almost complete, but the `log4j-to-slf4j` bridge probably needs an SLF4J2 version (module) to profit from the new SLF4J 2.0 features.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] ppkarwasz commented on pull request #1022: SLF4J2

Posted by GitBox <gi...@apache.org>.
ppkarwasz commented on PR #1022:
URL: https://github.com/apache/logging-log4j2/pull/1022#issuecomment-1228844598

   Hi @terrettaz,
   
   Thank you for you contribution. Since the SLF4J binding should go in the `log4j-slf4j20-impl` module, I have merged the `slf4j-2.0` branch into `release-2.0`. Can you rewrite your contribution in the new Maven module?
   
   Regarding the stack-valued MDC implementation, there is [an ongoing thread](https://lists.apache.org/thread/pzmqt2ypjgcttj93hconqgg16thyf81o) on the `dev` mailing list regarding the proper course of action. This is something that requires a consensus among devs and you are more than welcome to express your opinion.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] ppkarwasz closed pull request #1022: SLF4J2

Posted by GitBox <gi...@apache.org>.
ppkarwasz closed pull request #1022: SLF4J2
URL: https://github.com/apache/logging-log4j2/pull/1022


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] terrettaz commented on pull request #1022: SLF4J2

Posted by GitBox <gi...@apache.org>.
terrettaz commented on PR #1022:
URL: https://github.com/apache/logging-log4j2/pull/1022#issuecomment-1229148761

   Hi, thanks for the comments!
   I agree this is much better to use the new module and probably delete the slf4j18, I can include the deletion in this PR.
   
   I've checked the code of slf4j-reload4j or logback and I didn't really see the use of these new methods added in MDC. So in order to benefit from this new SLF4J api, I added the option to wire the top of the stack to the MDC of log4j. I added a unit-test to emphase the idea.
   I also prepare and option to activate this behaviour but didn't find the way to get options from the config. Any suggestion from the core developers on how to properly configure log4j-slf4j20-impl
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] terrettaz commented on pull request #1022: SLF4J2

Posted by GitBox <gi...@apache.org>.
terrettaz commented on PR #1022:
URL: https://github.com/apache/logging-log4j2/pull/1022#issuecomment-1230815167

   @ppkarwasz Thanks you for your comments!
   I still pushed one commit in my branch you might be interested in. I added several unit tests to cover different corner cases especially when Log4j NDC is used along with MDC.pushByKey(null, "value")


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] rgoers commented on pull request #1022: SLF4J2

Posted by GitBox <gi...@apache.org>.
rgoers commented on PR #1022:
URL: https://github.com/apache/logging-log4j2/pull/1022#issuecomment-1228845543

   I have two concerns with this:
   
   1. Because this upgrades log4j-slf4j18-impl to SLF4J 2.0 anyone using SLF4J 1.8 might have problems. That said, 1.8 never had a GA release. So I believe we should release the 2.0 module and remove the 1.8 module.
   2. From what I can tell the NDC queue is private to Log4jMdcAdapter. Thus log4j has no knowledge of it at all, which means it might as well have been implemented as a no-op.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] ppkarwasz commented on a diff in pull request #1022: SLF4J2

Posted by GitBox <gi...@apache.org>.
ppkarwasz commented on code in PR #1022:
URL: https://github.com/apache/logging-log4j2/pull/1022#discussion_r956561066


##########
log4j-slf4j20-impl/src/main/java/org/apache/logging/slf4j/Log4jMDCAdapter.java:
##########
@@ -27,57 +29,229 @@
  */
 public class Log4jMDCAdapter implements MDCAdapter {
 
+    private final MDCAdapter adapterDelegate;
+
+    public Log4jMDCAdapter(boolean enableSlf4jStack) {
+        if (enableSlf4jStack) {
+            adapterDelegate = new ExtendedMDCAdaptor();
+        } else {
+            adapterDelegate = new StandardMDCAdaptor();
+        }
+    }
+
     @Override
-    public void put(final String key, final String val) {
-        ThreadContext.put(key, val);
+    public void put(String key, String val) {
+        adapterDelegate.put(key, val);
     }
 
     @Override
-    public String get(final String key) {
-        return ThreadContext.get(key);
+    public String get(String key) {
+        return adapterDelegate.get(key);
     }
 
     @Override
-    public void remove(final String key) {
-        ThreadContext.remove(key);
+    public void remove(String key) {
+        adapterDelegate.remove(key);
     }
 
     @Override
     public void clear() {
-        ThreadContext.clearMap();
+        adapterDelegate.clear();
     }
 
     @Override
     public Map<String, String> getCopyOfContextMap() {
-        return ThreadContext.getContext();
+        return adapterDelegate.getCopyOfContextMap();
     }
 
     @Override
-    @SuppressWarnings("unchecked") // nothing we can do about this, restricted by SLF4J API
-    public void setContextMap(@SuppressWarnings("rawtypes") final Map map) {
-        ThreadContext.clearMap();
-        ThreadContext.putAll(map);
+    public void setContextMap(Map<String, String> contextMap) {
+        adapterDelegate.setContextMap(contextMap);
     }
 
     @Override
     public void pushByKey(String key, String value) {
-        // not implemented yet
+        adapterDelegate.pushByKey(key, value);
     }
 
     @Override
     public String popByKey(String key) {
-        // not implemented yet
-        return null;
+        return adapterDelegate.popByKey(key);
     }
 
     @Override
     public Deque<String> getCopyOfDequeByKey(String key) {
-        // not implemented yet
-        return null;
+        return adapterDelegate.getCopyOfDequeByKey(key);
     }
 
     @Override
     public void clearDequeByKey(String key) {
-        // not implemented yet
+        adapterDelegate.clearDequeByKey(key);
+    }
+
+    private static class StandardMDCAdaptor implements MDCAdapter {
+
+        @Override
+        public void put(final String key, final String val) {
+            ThreadContext.put(key, val);
+        }
+
+        @Override
+        public String get(final String key) {
+            return ThreadContext.get(key);
+        }
+
+        @Override
+        public void remove(final String key) {
+            ThreadContext.remove(key);
+        }
+
+        @Override
+        public void clear() {
+            ThreadContext.clearMap();
+        }
+
+        @Override
+        public Map<String, String> getCopyOfContextMap() {
+            return ThreadContext.getContext();
+        }
+
+        @Override
+        public void setContextMap(final Map<String, String> map) {
+            ThreadContext.clearMap();
+            ThreadContext.putAll(map);
+        }
+
+        @Override
+        public void pushByKey(String key, String value) {
+            // NOP
+        }
+
+        @Override
+        public String popByKey(String key) {
+            // NOP
+            return null;
+        }
+
+        @Override
+        public Deque<String> getCopyOfDequeByKey(String key) {
+            // NOP
+            return null;
+        }
+
+        @Override
+        public void clearDequeByKey(String key) {
+            // NOP
+        }
+    }
+
+    /**
+     * Wires the top of the stack to the MDC current value
+     */
+    private static final class ExtendedMDCAdaptor extends StandardMDCAdaptor {
+
+        private final ThreadLocalMapOfStacks   threadLocalMapOfDeques = new ThreadLocalMapOfStacks();
+
+        @Override
+        public void clear() {
+            super.clear();
+            threadLocalMapOfDeques.clear();
+        }
+
+        @Override
+        public void pushByKey(String key, String value) {
+            threadLocalMapOfDeques.pushByKey(key, value);
+            put(key, value);
+        }
+
+        @Override
+        public String popByKey(String key) {
+            String value = threadLocalMapOfDeques.popByKey(key);
+            String head = threadLocalMapOfDeques.peekByKey(key);
+            if (head != null) {
+                put(key, head);
+            }
+            return value;
+        }
+
+        @Override
+        public Deque<String> getCopyOfDequeByKey(String key) {
+            return threadLocalMapOfDeques.getCopyOfDequeByKey(key);
+        }
+
+        @Override
+        public void clearDequeByKey(String key) {
+            threadLocalMapOfDeques.clearDequeByKey(key);
+        }
+    }
+
+    /**
+     * A simple implementation of ThreadLocal backed Map containing values of type
+     * Deque<String>. This class is inspired from SLF4J version 2.0.0
+     */
+    private static final class ThreadLocalMapOfStacks {
+
+        private final ThreadLocal<Map<String, Deque<String>>> tlMapOfStacks = new ThreadLocal<>();
+
+        void pushByKey(String key, String value) {
+            if (key == null)
+                return;
+
+            Map<String, Deque<String>> map = tlMapOfStacks.get();
+
+            if (map == null) {
+                map = new HashMap<>();
+                tlMapOfStacks.set(map);
+            }
+
+            Deque<String> deque = map.get(key);
+            if (deque == null) {
+                deque = new ArrayDeque<>();
+            }
+            deque.push(value);
+            map.put(key, deque);

Review Comment:
   We could issue a warning if the `key` is already used in the classical MDC (`ThreadContext.get() != null`) (cf. [SLF4J-531](https://jira.qos.ch/browse/SLF4J-531) and return.
   
   There is really no reason to allow users to use the same `key` in both the classical and stack-based MDC.



##########
log4j-slf4j20-impl/src/main/java/org/apache/logging/slf4j/Log4jMDCAdapter.java:
##########
@@ -27,57 +29,229 @@
  */
 public class Log4jMDCAdapter implements MDCAdapter {
 
+    private final MDCAdapter adapterDelegate;
+
+    public Log4jMDCAdapter(boolean enableSlf4jStack) {
+        if (enableSlf4jStack) {
+            adapterDelegate = new ExtendedMDCAdaptor();
+        } else {
+            adapterDelegate = new StandardMDCAdaptor();
+        }
+    }
+
     @Override
-    public void put(final String key, final String val) {
-        ThreadContext.put(key, val);
+    public void put(String key, String val) {
+        adapterDelegate.put(key, val);
     }
 
     @Override
-    public String get(final String key) {
-        return ThreadContext.get(key);
+    public String get(String key) {
+        return adapterDelegate.get(key);
     }
 
     @Override
-    public void remove(final String key) {
-        ThreadContext.remove(key);
+    public void remove(String key) {
+        adapterDelegate.remove(key);
     }
 
     @Override
     public void clear() {
-        ThreadContext.clearMap();
+        adapterDelegate.clear();
     }
 
     @Override
     public Map<String, String> getCopyOfContextMap() {
-        return ThreadContext.getContext();
+        return adapterDelegate.getCopyOfContextMap();
     }
 
     @Override
-    @SuppressWarnings("unchecked") // nothing we can do about this, restricted by SLF4J API
-    public void setContextMap(@SuppressWarnings("rawtypes") final Map map) {
-        ThreadContext.clearMap();
-        ThreadContext.putAll(map);
+    public void setContextMap(Map<String, String> contextMap) {
+        adapterDelegate.setContextMap(contextMap);
     }
 
     @Override
     public void pushByKey(String key, String value) {
-        // not implemented yet
+        adapterDelegate.pushByKey(key, value);
     }
 
     @Override
     public String popByKey(String key) {
-        // not implemented yet
-        return null;
+        return adapterDelegate.popByKey(key);
     }
 
     @Override
     public Deque<String> getCopyOfDequeByKey(String key) {
-        // not implemented yet
-        return null;
+        return adapterDelegate.getCopyOfDequeByKey(key);
     }
 
     @Override
     public void clearDequeByKey(String key) {
-        // not implemented yet
+        adapterDelegate.clearDequeByKey(key);
+    }
+
+    private static class StandardMDCAdaptor implements MDCAdapter {
+
+        @Override
+        public void put(final String key, final String val) {
+            ThreadContext.put(key, val);
+        }
+
+        @Override
+        public String get(final String key) {
+            return ThreadContext.get(key);
+        }
+
+        @Override
+        public void remove(final String key) {
+            ThreadContext.remove(key);
+        }
+
+        @Override
+        public void clear() {
+            ThreadContext.clearMap();
+        }
+
+        @Override
+        public Map<String, String> getCopyOfContextMap() {
+            return ThreadContext.getContext();
+        }
+
+        @Override
+        public void setContextMap(final Map<String, String> map) {
+            ThreadContext.clearMap();
+            ThreadContext.putAll(map);
+        }
+
+        @Override
+        public void pushByKey(String key, String value) {
+            // NOP
+        }
+
+        @Override
+        public String popByKey(String key) {
+            // NOP
+            return null;
+        }
+
+        @Override
+        public Deque<String> getCopyOfDequeByKey(String key) {
+            // NOP
+            return null;
+        }
+
+        @Override
+        public void clearDequeByKey(String key) {
+            // NOP
+        }
+    }
+
+    /**
+     * Wires the top of the stack to the MDC current value
+     */
+    private static final class ExtendedMDCAdaptor extends StandardMDCAdaptor {
+
+        private final ThreadLocalMapOfStacks   threadLocalMapOfDeques = new ThreadLocalMapOfStacks();
+
+        @Override
+        public void clear() {
+            super.clear();
+            threadLocalMapOfDeques.clear();
+        }
+
+        @Override
+        public void pushByKey(String key, String value) {
+            threadLocalMapOfDeques.pushByKey(key, value);
+            put(key, value);
+        }
+
+        @Override
+        public String popByKey(String key) {
+            String value = threadLocalMapOfDeques.popByKey(key);
+            String head = threadLocalMapOfDeques.peekByKey(key);
+            if (head != null) {
+                put(key, head);
+            }
+            return value;
+        }
+
+        @Override
+        public Deque<String> getCopyOfDequeByKey(String key) {
+            return threadLocalMapOfDeques.getCopyOfDequeByKey(key);
+        }
+
+        @Override
+        public void clearDequeByKey(String key) {
+            threadLocalMapOfDeques.clearDequeByKey(key);
+        }
+    }
+
+    /**
+     * A simple implementation of ThreadLocal backed Map containing values of type
+     * Deque<String>. This class is inspired from SLF4J version 2.0.0
+     */
+    private static final class ThreadLocalMapOfStacks {

Review Comment:
   I wouldn't copy this class, but just use the one Ceki provides in `slf4j-api`.



##########
log4j-slf4j20-impl/src/main/java/org/apache/logging/slf4j/Log4jMDCAdapter.java:
##########
@@ -27,57 +29,229 @@
  */
 public class Log4jMDCAdapter implements MDCAdapter {
 
+    private final MDCAdapter adapterDelegate;
+
+    public Log4jMDCAdapter(boolean enableSlf4jStack) {
+        if (enableSlf4jStack) {
+            adapterDelegate = new ExtendedMDCAdaptor();
+        } else {
+            adapterDelegate = new StandardMDCAdaptor();
+        }
+    }
+
     @Override
-    public void put(final String key, final String val) {
-        ThreadContext.put(key, val);
+    public void put(String key, String val) {
+        adapterDelegate.put(key, val);
     }
 
     @Override
-    public String get(final String key) {
-        return ThreadContext.get(key);
+    public String get(String key) {
+        return adapterDelegate.get(key);
     }
 
     @Override
-    public void remove(final String key) {
-        ThreadContext.remove(key);
+    public void remove(String key) {
+        adapterDelegate.remove(key);
     }
 
     @Override
     public void clear() {
-        ThreadContext.clearMap();
+        adapterDelegate.clear();
     }
 
     @Override
     public Map<String, String> getCopyOfContextMap() {
-        return ThreadContext.getContext();
+        return adapterDelegate.getCopyOfContextMap();
     }
 
     @Override
-    @SuppressWarnings("unchecked") // nothing we can do about this, restricted by SLF4J API
-    public void setContextMap(@SuppressWarnings("rawtypes") final Map map) {
-        ThreadContext.clearMap();
-        ThreadContext.putAll(map);
+    public void setContextMap(Map<String, String> contextMap) {
+        adapterDelegate.setContextMap(contextMap);
     }
 
     @Override
     public void pushByKey(String key, String value) {
-        // not implemented yet
+        adapterDelegate.pushByKey(key, value);
     }
 
     @Override
     public String popByKey(String key) {
-        // not implemented yet
-        return null;
+        return adapterDelegate.popByKey(key);
     }
 
     @Override
     public Deque<String> getCopyOfDequeByKey(String key) {
-        // not implemented yet
-        return null;
+        return adapterDelegate.getCopyOfDequeByKey(key);
     }
 
     @Override
     public void clearDequeByKey(String key) {
-        // not implemented yet
+        adapterDelegate.clearDequeByKey(key);
+    }
+
+    private static class StandardMDCAdaptor implements MDCAdapter {
+
+        @Override
+        public void put(final String key, final String val) {
+            ThreadContext.put(key, val);
+        }
+
+        @Override
+        public String get(final String key) {
+            return ThreadContext.get(key);
+        }
+
+        @Override
+        public void remove(final String key) {
+            ThreadContext.remove(key);
+        }
+
+        @Override
+        public void clear() {
+            ThreadContext.clearMap();
+        }
+
+        @Override
+        public Map<String, String> getCopyOfContextMap() {
+            return ThreadContext.getContext();
+        }
+
+        @Override
+        public void setContextMap(final Map<String, String> map) {
+            ThreadContext.clearMap();
+            ThreadContext.putAll(map);
+        }
+
+        @Override
+        public void pushByKey(String key, String value) {
+            // NOP
+        }
+
+        @Override
+        public String popByKey(String key) {
+            // NOP
+            return null;
+        }
+
+        @Override
+        public Deque<String> getCopyOfDequeByKey(String key) {
+            // NOP
+            return null;
+        }
+
+        @Override
+        public void clearDequeByKey(String key) {
+            // NOP
+        }
+    }
+
+    /**
+     * Wires the top of the stack to the MDC current value
+     */
+    private static final class ExtendedMDCAdaptor extends StandardMDCAdaptor {
+
+        private final ThreadLocalMapOfStacks   threadLocalMapOfDeques = new ThreadLocalMapOfStacks();
+
+        @Override
+        public void clear() {
+            super.clear();
+            threadLocalMapOfDeques.clear();
+        }
+
+        @Override
+        public void pushByKey(String key, String value) {
+            threadLocalMapOfDeques.pushByKey(key, value);
+            put(key, value);
+        }
+
+        @Override
+        public String popByKey(String key) {
+            String value = threadLocalMapOfDeques.popByKey(key);
+            String head = threadLocalMapOfDeques.peekByKey(key);
+            if (head != null) {
+                put(key, head);
+            }
+            return value;
+        }
+
+        @Override
+        public Deque<String> getCopyOfDequeByKey(String key) {
+            return threadLocalMapOfDeques.getCopyOfDequeByKey(key);
+        }
+
+        @Override
+        public void clearDequeByKey(String key) {
+            threadLocalMapOfDeques.clearDequeByKey(key);
+        }
+    }
+
+    /**
+     * A simple implementation of ThreadLocal backed Map containing values of type
+     * Deque<String>. This class is inspired from SLF4J version 2.0.0
+     */
+    private static final class ThreadLocalMapOfStacks {
+
+        private final ThreadLocal<Map<String, Deque<String>>> tlMapOfStacks = new ThreadLocal<>();
+
+        void pushByKey(String key, String value) {
+            if (key == null)
+                return;

Review Comment:
   If the `key` is `null` I would delegate to `ThreadContext.push` to take advantage of our NDC.



##########
log4j-slf4j20-impl/src/main/java/org/apache/logging/slf4j/Log4jMDCAdapter.java:
##########
@@ -27,57 +29,229 @@
  */
 public class Log4jMDCAdapter implements MDCAdapter {
 
+    private final MDCAdapter adapterDelegate;
+
+    public Log4jMDCAdapter(boolean enableSlf4jStack) {
+        if (enableSlf4jStack) {
+            adapterDelegate = new ExtendedMDCAdaptor();
+        } else {
+            adapterDelegate = new StandardMDCAdaptor();
+        }
+    }
+
     @Override
-    public void put(final String key, final String val) {
-        ThreadContext.put(key, val);
+    public void put(String key, String val) {
+        adapterDelegate.put(key, val);
     }
 
     @Override
-    public String get(final String key) {
-        return ThreadContext.get(key);
+    public String get(String key) {
+        return adapterDelegate.get(key);
     }
 
     @Override
-    public void remove(final String key) {
-        ThreadContext.remove(key);
+    public void remove(String key) {
+        adapterDelegate.remove(key);
     }
 
     @Override
     public void clear() {
-        ThreadContext.clearMap();
+        adapterDelegate.clear();
     }
 
     @Override
     public Map<String, String> getCopyOfContextMap() {
-        return ThreadContext.getContext();
+        return adapterDelegate.getCopyOfContextMap();
     }
 
     @Override
-    @SuppressWarnings("unchecked") // nothing we can do about this, restricted by SLF4J API
-    public void setContextMap(@SuppressWarnings("rawtypes") final Map map) {
-        ThreadContext.clearMap();
-        ThreadContext.putAll(map);
+    public void setContextMap(Map<String, String> contextMap) {
+        adapterDelegate.setContextMap(contextMap);
     }
 
     @Override
     public void pushByKey(String key, String value) {
-        // not implemented yet
+        adapterDelegate.pushByKey(key, value);
     }
 
     @Override
     public String popByKey(String key) {
-        // not implemented yet
-        return null;
+        return adapterDelegate.popByKey(key);
     }
 
     @Override
     public Deque<String> getCopyOfDequeByKey(String key) {
-        // not implemented yet
-        return null;
+        return adapterDelegate.getCopyOfDequeByKey(key);
     }
 
     @Override
     public void clearDequeByKey(String key) {
-        // not implemented yet
+        adapterDelegate.clearDequeByKey(key);
+    }
+
+    private static class StandardMDCAdaptor implements MDCAdapter {
+
+        @Override
+        public void put(final String key, final String val) {
+            ThreadContext.put(key, val);
+        }
+
+        @Override
+        public String get(final String key) {
+            return ThreadContext.get(key);
+        }
+
+        @Override
+        public void remove(final String key) {
+            ThreadContext.remove(key);
+        }
+
+        @Override
+        public void clear() {
+            ThreadContext.clearMap();
+        }
+
+        @Override
+        public Map<String, String> getCopyOfContextMap() {
+            return ThreadContext.getContext();
+        }
+
+        @Override
+        public void setContextMap(final Map<String, String> map) {
+            ThreadContext.clearMap();
+            ThreadContext.putAll(map);
+        }
+
+        @Override
+        public void pushByKey(String key, String value) {
+            // NOP
+        }
+
+        @Override
+        public String popByKey(String key) {
+            // NOP
+            return null;
+        }
+
+        @Override
+        public Deque<String> getCopyOfDequeByKey(String key) {
+            // NOP
+            return null;
+        }
+
+        @Override
+        public void clearDequeByKey(String key) {
+            // NOP
+        }
+    }
+
+    /**
+     * Wires the top of the stack to the MDC current value
+     */
+    private static final class ExtendedMDCAdaptor extends StandardMDCAdaptor {

Review Comment:
   Personally I am fine with this implementation being the only one.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] TWiStErRob commented on pull request #1022: SLF4J2

Posted by GitBox <gi...@apache.org>.
TWiStErRob commented on PR #1022:
URL: https://github.com/apache/logging-log4j2/pull/1022#issuecomment-1229431231

   As a user [agree with @rgoers's 1)](https://github.com/apache/logging-log4j2/pull/1022#issuecomment-1228845543). I found found the "18" artifact useful for migration, as it works nicely with SLF4J2, but it's confusing, because there was no such release of SLF4J.
   
   Feedback: I ended up here, because I wanted to PR a doc fix for this page:
   https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/index.html
   again, it's confusing it refers to "1.8" when there's no such [stable release](https://mvnrepository.com/artifact/org.slf4j/slf4j-api). I believe this should be also included in this PR or a following one.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] terrettaz commented on pull request #1022: SLF4J2

Posted by GitBox <gi...@apache.org>.
terrettaz commented on PR #1022:
URL: https://github.com/apache/logging-log4j2/pull/1022#issuecomment-1230539992

   > @terrettaz,
   > 
   > I modified your original PR to work with the current pattern converters (#1025). What name should I put in the release notes?
   
   I am still working on this PR to include all your comment, should be finish soon.
   
   About my name: Pierrick Terrettaz
   Thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j2] ppkarwasz commented on pull request #1022: SLF4J2

Posted by GitBox <gi...@apache.org>.
ppkarwasz commented on PR #1022:
URL: https://github.com/apache/logging-log4j2/pull/1022#issuecomment-1230447400

   @terrettaz,
   
   I modified your original PR to work with the current pattern converters (#1025). What name should I put in the release notes?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org