[ 
https://issues.apache.org/jira/browse/ROCKETMQ-359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16383489#comment-16383489
 ] 

ASF GitHub Bot commented on ROCKETMQ-359:
-----------------------------------------

lindzh commented on a change in pull request #221: [ROCKETMQ-359] Replace slf4j 
api used in RocketMQ with InternalLogger
URL: https://github.com/apache/rocketmq/pull/221#discussion_r171825186
 
 

 ##########
 File path: 
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyLogger.java
 ##########
 @@ -0,0 +1,316 @@
+/*
+ * 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.rocketmq.remoting.netty;
+
+
+import io.netty.util.internal.logging.InternalLogLevel;
+import org.apache.rocketmq.logging.InternalLogger;
+import org.apache.rocketmq.logging.InternalLoggerFactory;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class NettyLogger {
+
+    private static AtomicBoolean nettyLoggerSeted = new AtomicBoolean(false);
+    
+    private static InternalLogLevel nettyLogLevel = InternalLogLevel.ERROR;
+
+    public static void initNettyLogger() {
+        if (!nettyLoggerSeted.get()) {
+            try {
+                
io.netty.util.internal.logging.InternalLoggerFactory.setDefaultFactory(new 
NettyBridgeLoggerFactory());
+            } catch (Throwable e) {
+                //ignore
+            }
+            nettyLoggerSeted.set(true);
+        }
+    }
+
+    private static class NettyBridgeLoggerFactory extends 
io.netty.util.internal.logging.InternalLoggerFactory {
+        @Override
+        protected io.netty.util.internal.logging.InternalLogger 
newInstance(String s) {
+            return new NettyBridgeLogger(s);
+        }
+    }
+
+    private static class NettyBridgeLogger implements 
io.netty.util.internal.logging.InternalLogger {
+
+        private InternalLogger logger = null;
+
+        public NettyBridgeLogger(String name) {
+            logger = InternalLoggerFactory.getLogger(name);
+        }
+
+        @Override
+        public String name() {
+            return logger.getName();
+        }
+
+        // FIXME: 2018/3/2 
 
 Review comment:
   Fixme has been deleted.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Replace slf4j api used in RocketMQ with InternalLogger
> ------------------------------------------------------
>
>                 Key: ROCKETMQ-359
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-359
>             Project: Apache RocketMQ
>          Issue Type: Improvement
>    Affects Versions: 4.2.0
>            Reporter: lindzh
>            Assignee: vongosling
>            Priority: Major
>             Fix For: 4.3.0
>
>
> Since Logger is used any where and there is many loggers for us to choose,In 
> many cases we have to isolate our logger with other loggers. In my opinion 
> use an isolated logger is necessary.
> ------------------------- logging isolation has been fix with logging 
> component
> And it is necessary to replace slf4j api used in RocketMQ with InternalLogger 
> now!



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to