You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/10/27 06:49:28 UTC

[GitHub] [shardingsphere] ziliangzeng opened a new issue #13307: Referencing sharding-jdbc and log4j-over-slf4j at the same time will cause conflicts. What is the specific reason?

ziliangzeng opened a new issue #13307:
URL: https://github.com/apache/shardingsphere/issues/13307


   ## Question
   I try to introduce sharding-jdbc into the old project. The project used org.slf4j:log4j-over-slf4j:1.7.26 before, which would cause conflicts to fail. Try to check the dependency package of sharding-jdbc and find that org.slf4j:log4j-over-slf4j is not referenced. Will different dependencies affect each other? Is there any way to deal with it? Thank you.
   
   ## version
     org.apache.shardingsphere:shardingsphere-jdbc-core:5.0.0-beta
     org.slf4j:log4j-over-slf4j:1.7.26
   
   ##code 
    - pom.xml
       `<dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>shardingsphere-jdbc-core</artifactId>
               <version>5.0.0-beta</version>
           </dependency>
           <dependency>
               <groupId>org.slf4j</groupId>
               <artifactId>log4j-over-slf4j</artifactId>
               <version>1.7.26</version>
           </dependency>
   `
   - Elklog
     `
   package com.example.shardingspheredemo.controller;
   import org.apache.log4j.Logger;
   import org.slf4j.spi.LocationAwareLogger;
   import java.util.HashMap;
   import java.util.Map;
   public abstract class ElkLog extends Logger {
       private static final Logger logger = Logger.getLogger(ElkLog.class);
       private static final String ELK_FQCN = ElkLog.class.getName();
       protected ElkLog(String name) {
           super(name);
       }
      
       public static ElkLog getElkLog(Class<? extends ElkLog> logClass) {
           try {
               return logClass.newInstance();
           } catch (Exception e) {
               logger.error("elk日志类"+logClass.getName()+"实例化失败", e);
           }
           return null;
       }
       /**
        * 打印日志
        * @param level
        * @param t
        */
       protected void setLog(int level, Throwable t, Map<String, String> map, String fqcn) {
           String msg = map.toString();
           **//slf4jLogger cannot be used**
           if (slf4jLogger instanceof LocationAwareLogger) {
               LocationAwareLogger locationAwareLogger = (LocationAwareLogger) slf4jLogger;
               locationAwareLogger.log(null, fqcn, level, msg, null, t);
           } else {
               switch (level) {
                   case LocationAwareLogger.INFO_INT:
                       slf4jLogger.info(null, (Object) msg);
                       break;
                   case LocationAwareLogger.ERROR_INT:
                       slf4jLogger.error(null, (Object) msg);
                       break;
                   default: break;
               }
           }
   
       }
   
       private void setLog(int level, Throwable t, Map<String, String> map) {
           setLog(level, t, map, ELK_FQCN);
   
       }
   
       protected void log(int logLevel, String username, String extend1, String extend2,
                          String message, Throwable t, String fqcn) {
   
           Map<String, String> msgField = new HashMap<>();
           //时间
           msgField.put("dateTime", String.valueOf(System.currentTimeMillis()));
   
           msgField.put("username", username);
           msgField.put("extend1", extend1);
           msgField.put("extend2", extend2);
           msgField.put("message", message);
   
           //打印日志
           setLog(logLevel, t, msgField, fqcn);
       }
   
       private void log(int logLevel, String username, String extend1, String extend2
               , String message, Throwable t) {
           log(logLevel, username, extend1, extend2, message, t, ELK_FQCN);
       }
   
       public void info(String username, String extend1, String extend2, String message) {
           log(LocationAwareLogger.INFO_INT, username, extend1, extend2, message, null);
       }
   
       public void error(String username, String extend1, String extend2, String message, Throwable t) {
           log(LocationAwareLogger.ERROR_INT, username, extend1, extend2, message, t);
       }
       public void usernameInfo(String username, String message) {
           log(LocationAwareLogger.INFO_INT, username,null,null, message,null);
       }
       public void usernameError(String username, String message, Throwable t) {
           log(LocationAwareLogger.ERROR_INT, username, null, null, message, t);
       }
   }
   
   `
   


-- 
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@shardingsphere.apache.org

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



[GitHub] [shardingsphere] zjcnb commented on issue #13307: Referencing sharding-jdbc and log4j-over-slf4j at the same time will cause conflicts. What is the specific reason?

Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #13307:
URL: https://github.com/apache/shardingsphere/issues/13307#issuecomment-952634928


   > Hi @zjcnb Could you check this issue?
   
   ok, 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@shardingsphere.apache.org

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



[GitHub] [shardingsphere] zjcnb edited a comment on issue #13307: Referencing sharding-jdbc and log4j-over-slf4j at the same time will cause conflicts. What is the specific reason?

Posted by GitBox <gi...@apache.org>.
zjcnb edited a comment on issue #13307:
URL: https://github.com/apache/shardingsphere/issues/13307#issuecomment-952670075


   @ziliangzeng Hi, the `shardingsphere-db-discovery-core`moudle is about MySQL HA, you can exclusion it If you not use it


-- 
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@shardingsphere.apache.org

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



[GitHub] [shardingsphere] ziliangzeng closed issue #13307: Referencing sharding-jdbc and log4j-over-slf4j at the same time will cause conflicts. What is the specific reason?

Posted by GitBox <gi...@apache.org>.
ziliangzeng closed issue #13307:
URL: https://github.com/apache/shardingsphere/issues/13307


   


-- 
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@shardingsphere.apache.org

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



[GitHub] [shardingsphere] ziliangzeng commented on issue #13307: Referencing sharding-jdbc and log4j-over-slf4j at the same time will cause conflicts. What is the specific reason?

Posted by GitBox <gi...@apache.org>.
ziliangzeng commented on issue #13307:
URL: https://github.com/apache/shardingsphere/issues/13307#issuecomment-952607438


   By using the method of elimination, I found that `<exclusion>
                   <groupId>org.apache.shardingsphere</groupId>
                   <artifactId>shardingsphere-db-discovery-core</artifactId>
                   </exclusion>`
   is The main cause of conflict
   What kind of problems will it cause if I exclude this dependency? What is this module used for?


-- 
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@shardingsphere.apache.org

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



[GitHub] [shardingsphere] zjcnb commented on issue #13307: Referencing sharding-jdbc and log4j-over-slf4j at the same time will cause conflicts. What is the specific reason?

Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #13307:
URL: https://github.com/apache/shardingsphere/issues/13307#issuecomment-952670075


   @ziliangzeng Hi, the `shardingsphere-db-discovery-core` moudle is about MySQL HA, you can exclusion it If you not use it


-- 
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@shardingsphere.apache.org

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



[GitHub] [shardingsphere] ziliangzeng commented on issue #13307: Referencing sharding-jdbc and log4j-over-slf4j at the same time will cause conflicts. What is the specific reason?

Posted by GitBox <gi...@apache.org>.
ziliangzeng commented on issue #13307:
URL: https://github.com/apache/shardingsphere/issues/13307#issuecomment-952674582


   ok,thank you. @zjcnb 


-- 
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@shardingsphere.apache.org

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



[GitHub] [shardingsphere] zjcnb edited a comment on issue #13307: Referencing sharding-jdbc and log4j-over-slf4j at the same time will cause conflicts. What is the specific reason?

Posted by GitBox <gi...@apache.org>.
zjcnb edited a comment on issue #13307:
URL: https://github.com/apache/shardingsphere/issues/13307#issuecomment-952670075


   @ziliangzeng Hi, the `shardingsphere-db-discovery-core` module is about MySQL HA, you can exclusion it If you not use it


-- 
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@shardingsphere.apache.org

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



[GitHub] [shardingsphere] ziliangzeng edited a comment on issue #13307: Referencing sharding-jdbc and log4j-over-slf4j at the same time will cause conflicts. What is the specific reason?

Posted by GitBox <gi...@apache.org>.
ziliangzeng edited a comment on issue #13307:
URL: https://github.com/apache/shardingsphere/issues/13307#issuecomment-952607438


   By using the method of Exclusion, I found that `<exclusion>
                   <groupId>org.apache.shardingsphere</groupId>
                   <artifactId>shardingsphere-db-discovery-core</artifactId>
                   </exclusion>`
   is The main cause of conflict
   What kind of problems will it cause if I exclude this dependency? What is this module used for?


-- 
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@shardingsphere.apache.org

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



[GitHub] [shardingsphere] TeslaCN commented on issue #13307: Referencing sharding-jdbc and log4j-over-slf4j at the same time will cause conflicts. What is the specific reason?

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on issue #13307:
URL: https://github.com/apache/shardingsphere/issues/13307#issuecomment-952627376


   Hi @ziliangzeng 
   Thanks for your feedback! Welcome to investigate this issue if you are interested in, or we will do it later.


-- 
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@shardingsphere.apache.org

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



[GitHub] [shardingsphere] TeslaCN commented on issue #13307: Referencing sharding-jdbc and log4j-over-slf4j at the same time will cause conflicts. What is the specific reason?

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on issue #13307:
URL: https://github.com/apache/shardingsphere/issues/13307#issuecomment-952632217


   Hi @zjcnb 
   Could you check this issue?


-- 
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@shardingsphere.apache.org

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



[GitHub] [shardingsphere] ziliangzeng commented on issue #13307: Referencing sharding-jdbc and log4j-over-slf4j at the same time will cause conflicts. What is the specific reason?

Posted by GitBox <gi...@apache.org>.
ziliangzeng commented on issue #13307:
URL: https://github.com/apache/shardingsphere/issues/13307#issuecomment-952994636


   At night tonight, I discovered that the final conflict part is 
   `<dependency>
               <groupId>org.apache.shardingsphere</groupId>
               <artifactId>shardingsphere-jdbc-core</artifactId>
               <version>5.0.0-beta</version>
               <exclusions>
                   <exclusion>
                       <groupId>log4j</groupId>
                       <artifactId>log4j</artifactId>
                   </exclusion>
               </exclusions>
           </dependency>`


-- 
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@shardingsphere.apache.org

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