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

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

Github user Jaskey commented on a diff in the pull request:

    https://github.com/apache/incubator-rocketmq/pull/85#discussion_r111524822
  
    --- Diff: 
common/src/main/java/org/apache/rocketmq/common/utils/LogUtils.java ---
    @@ -0,0 +1,96 @@
    +/*
    + * 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.common.utils;
    +
    +import java.lang.reflect.InvocationTargetException;
    +import java.lang.reflect.Method;
    +import java.net.URL;
    +import org.slf4j.ILoggerFactory;
    +import org.slf4j.LoggerFactory;
    +
    +public class LogUtils {
    +
    +    /**
    +     * config logback dymatically from provided file path, otherwise try 
to config from resource file
    +     * @param logConfigFilePath specified logback configuration file path
    +     * @param logbackResourceFile specified logback configuration resource 
file, which will only be respected when logConfigFilePath is null
    +     * @param iLoggerFactory
    +     * @throws ClassNotFoundException
    +     * @throws InstantiationException
    +     * @throws IllegalAccessException
    +     * @throws NoSuchMethodException
    +     * @throws InvocationTargetException
    +     */
    +    public static void configLogback(String logConfigFilePath, String 
logbackResourceFile, ILoggerFactory iLoggerFactory) throws 
ClassNotFoundException, InstantiationException, IllegalAccessException, 
NoSuchMethodException, InvocationTargetException {
    +        Class<?> joranConfigurator;
    +        Class<?> context = Class.forName("ch.qos.logback.core.Context");
    +        Object joranConfiguratoroObj;
    +        joranConfigurator = 
Class.forName("ch.qos.logback.classic.joran.JoranConfigurator");
    +        joranConfiguratoroObj = joranConfigurator.newInstance();
    +        Method setContext = 
joranConfiguratoroObj.getClass().getMethod("setContext", context);
    +        setContext.invoke(joranConfiguratoroObj, iLoggerFactory);
    +        if (null == logConfigFilePath) {
    +            if (logbackResourceFile != null) {
    +                URL url = 
LogUtils.class.getClassLoader().getResource(logbackResourceFile);
    +                Method doConfigure = 
joranConfiguratoroObj.getClass().getMethod("doConfigure", URL.class);
    +                doConfigure.invoke(joranConfiguratoroObj, url);
    +            }
    +        } else {
    +            Method doConfigure = 
joranConfiguratoroObj.getClass().getMethod("doConfigure", String.class);
    +            doConfigure.invoke(joranConfiguratoroObj, logConfigFilePath);
    +        }
    +    }
    +
    +    /**
    +     * config log4j dymatically from provided file path, otherwise try to 
config from resource file. Notice that the log4j configuration file should be 
in xml format
    --- End diff --
    
    Fixed, thank you!


> Remove logback dependency for rocketmq-tools
> --------------------------------------------
>
>                 Key: ROCKETMQ-158
>                 URL: https://issues.apache.org/jira/browse/ROCKETMQ-158
>             Project: Apache RocketMQ
>          Issue Type: Improvement
>          Components: rocketmq-tools
>            Reporter: Jaskey Lam
>            Assignee: Jaskey Lam
>            Priority: Minor
>
> Since user may need to use some admin interfaces to maintain something like 
> create topic, manage queues.
> They will need to use rocketmq-tools which contains DefaultMQAdminExt.
> But rocketmq-tools has explicitly depend on logback-classic and logback-core, 
> which may be conflict with the logging framework of the user's application.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to