Code Monkey home page Code Monkey logo

sofa-common-tools's People

Contributors

alaneuler avatar caojie09 avatar dependabot[bot] avatar dkisser avatar dreampie avatar duan-0916 avatar glmapper avatar guanchao-yang avatar hzjneverstop avatar khotyn avatar leizhiyuan avatar orezzero avatar qilongzhang avatar straybirdzls avatar stream-iori avatar ujjboy avatar weyuhui110 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sofa-common-tools's Issues

这个项目解决的问题是?

不是很理解这个项目的作用,到底是为了解决了什么问题?

根据 sofa-common-tools 的规范对常用日志实现(Logback、Log4j2 和 Log4j)均进行配置(配置日志输出文件和格式),当应用引入二方包或者中间件时,根据应用中已有的日志实现并选择该日志实现能够正确解析的配置文件来初始化完成二方包或者中间件的日志配置来完成日志的输出,并同时不会和某一个具体日志实现绑定。从而完成在不用业务配置额外的 appender 和 logger 或者业务不用修改任何配置的情况下,完成日志空间打印的隔离能力。

疑问1:
中间件或二方包引入什么日志框架,并不会影响到应用的的日志打印呀。
应用引入中间件或二方包,并不一定需要进行appender和logger配置的修改。
这些都可以通过slf4j提供的桥接包,或者log4j2提供的桥接包(log4j->log4j2)解决。
既然不影响,为什么要用sofa-common-tools包,将简单的问题搞复杂了。

疑问2:
“完成日志空间打印的隔离能力“
这里的空间隔离是指?是指打印到不同的日志文件?
如果是的话,这个完全可以通过将logger配置成包名,再配置相应的appender的方法解决。

对于三方包, 如何重定向二方包的日志输出?

Your question

对于三方包, 如何重定向依赖的三方包的日志输出?

Your scenes

我目前在开发一个中间件, 因为日志问题, 所以希望引入sofa-common-tools. 不过遇到一个问题. 我的中间件引入了其他的三方包, 一开始我是通过自定义appender将它的日志重定向到了希望的文件下, 但是引入了sofa-common-tools后发现重定向失败了. 我想这是和sofa-common-tools中所有logger必须通过自定义的LoggerFactory类来获取有关. 而且去改造引入的三方包是不可能的. 请问有什么好的解决方案?

Compatible old ReportUtil usage

Before some alipay users use ReportUtil with the full package com.alipay.sofa.common.log.ReportUtil but in this version ReportUtil has been moved to com.alipay.sofa.common.utils.ReportUtil. Consider many users has used, so we should be compatible with it

Terminate the support of JDK 6

As JDK and SOFABoot evolves, SOFABoot has already end the support of JDK 6, it's time to terminate the support of JDK 6.

Logger does not print the write package name

Describe the bug

image

See the above picture as an example, the package in the log should be the package that print the log, not com.alipay.sofa.common.log.

Steps to reproduce

add -Dsofa.middleware.log.disable=true to the VM options to reproduce the bug.

Environment

  • sofa-common-tools version:1.0.14
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

Local console logger support prefix match

Your question

describe your question clearly

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like

Environment

  • sofa-common-tools version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

LoggerSpaceManager should use caller classloader default

com.alipay.sofa.common.log.LoggerSpaceManager#getLoggerBySpace(java.lang.String, java.lang.String) as follow:

    public static Logger getLoggerBySpace(String name, String spaceName) {
        return getLoggerBySpace(name, new SpaceId(spaceName),
            Collections.<String, String> emptyMap());
    }

In order to support sofa ark environment, we should use caller classloader default.

DefaultConfigManger will cause concurrent problem

Describe the bug

A clear and concise description of what the bug is.

Expected behavior

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

Environment

  • sofa-common-tools version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

String Index out of range 问题

Describe the bug

com.alipay.sofa.common.boot.logging.CommonLoggingApplicationListener#reInitializeLog 方法中,入参 map 的一个 key 为sofa.middleware.log.disable,运行到第74行时,实际上是:

 int index = Constants.SOFA_MIDDLEWARE_CONFIG_PREFIX.length();//20
int end = "sofa.middleware.log.disable".length() - 9;//19
key.substring(20, 19)

然后就报错了

Expected behavior

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

Environment

  • sofa-common-tools version: 1.0.16
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

About Loglevel dynamic configuration implementation

该组件提供了修改日志级别的接口,我们准备对接自己的配置中心实现日志等级的动态配置,想咨询下你们是如何使用该组件实现的,未来是否会提供类似的功能比如对接一些配置中心比如zookeeper或者 Apollo Nacos 等

Provide global switch of all log namespaces.

Your question

Now, we can set -Dlogging.level.com.alipay.sofa.rpc=WARN to specify the log level of com.alipay.sofa.rpc.

Can we provider a global switch like logging.level.com.alipay.sofa.*=WARN to set log levels of all log namespace.

SpaceId设置和API动态配置日志级别的问题

您好,如下代码,然后两个问题是 SpaceId这个设置之后是和配置文件相对应的么,可以再加SpaceId怎么设置,这个场景是,那个动态日志级别是否是我代码中那个意思呢,感谢并期待您的回复
`/**
* SpaceId这个是自己规定的一个规范名字 可以理解为自己的日志空间
*/
public static final String SHOW_LOG_SPACE = "com.alipay.sofa.rpc";

/**
 * 可动态改变日志级别的打日志方法
 *
 * @param name         一般类名
 * @param adapterLevel 日志级别 info debug等
 * @return
 */
public static Logger getLogger(String name, AdapterLevel adapterLevel) {
    //这个是控制是否采用logback日志 true是关闭此日志用下个日志
    System.setProperty(Constants.LOGBACK_MIDDLEWARE_LOG_DISABLE_PROP_KEY, "true");
    //可以动态改变日志的级别
    return LoggerSpaceManager.setLoggerLevel(name, SHOW_LOG_SPACE, adapterLevel);
}`

getCallerClassLoader gets wrong classloader

getClallerClassLoader will try tccl first to load class.

However, in multi-classloader environment, above behavior will get the initial class loader not the caller classloader

Tools itself logging problem

sofa-common-tools's purpose is to address the concern of logging, but the logging of itself has problems.

Some of its classes needs to log too, while they use SLF4j whose configuration depends on user (which is absolutely hilarious). In general, users don't even know the issue, so the logs are all printed to stdout.

Add the ability the print the log into the console when running in the IDE.

Currently all the log will print to the corresponding log file when running application in the IDE, which make it inconvenient to find the log.

The only way to print all the log into the console is set a VM option -Dsofa.middleware.log.disable=true

We should provide a more convenient way to provide the ability to log all the file into the console.

咨询几个碰到的问题sofa-common-tools是否可以解决

您好,继续咨询几个问题:
1.假如我们现在的业务系统中已经引入了三方包,三方包用log4j打印的,我们业务系统准备用logback打印日志,那是说我们的业务系统要用sofa-common-tools打印日志吗?还是要求三方包改用这个框架打印日志?
2.假如好几个三方包有的用log4j打印日志,有的用logback打印日志,怎么解决他们的冲突问题?三方包我们无法要求别人修改代码了.
3.日志隔离的具体应用场景是什么那?我们的业务系统虽然引入了很多三方包,但是也没出现过日志冲突的问题,或者出现了我们可以通过调整配置也能解决他们冲突的问题,实现三方包和我们的业务系统同时打印日志.
4.动态日志级别的具体应用场景是什么那?感觉平时也用不到啊?

支持单独配置终端日志级别

sofa-common-tools 目前支持把 logger 的日志输出到文件的同时在 console 输出,但是目前的 level 是一样的,有时候 console 需要不同的日志级别,希望能够提供这个能力。

image

可能的做法:

  1. One may consider appender filer.
  2. AppenderControl is also applicable in log4j2.

Why logger init logs only printed on debug level?

Describe the bug

The logger init logs should not be printed only on debug level? Because this will make it's very difficult for trouble shooting.
image

Expected behavior

The logger init logs are printed on info level.

Actual behavior

The logger init logs are only printed on debug level.

Can't change root logger level for Log4j

Describe the bug

Can't change root logger level for Log4j

LoggerSpaceFactory4Log4jBuilder # setLevel()

Expected behavior

MayBe use ?

repo.getRootLogger().setLevel(this.toLog4jLevel(adapterLevel));

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or GitHub URL to code)

Environment

  • sofa-common-tools version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

Support for JDK/Spring ThreadPoolExecutor logging of decayed tasks

ThreadPoolExecutor has no built-in ability of logging for decayed tasks. Hope for there are:

  1. Customizable task timeout
  2. Periodically checking tasks for decaying
  3. Logging decayed tasks for auditing and debugging

Also, Spring's ThreadPoolTaskExecutor is also used widely, it's appreciated if this ExecutorService is also supported.

Provide a mechanism for guaranteeing error log output in console

When application started in IDE,error occurs during bootstrap and the error log output like common-error.log .When the commponents are too more ,the error output to file not easy to find。So, providing a mechanism for guaranteeing error log output in console when run in IDE for better experience

Better logger name where there are no known logging backend provided

Your question

Right now if the application class path does not contains a well-known logging backend (like Logback, Log4j and etc) the created logger gets fixed predefined name "com.alipay.sofa.common.log".

So if an app uses a library like SOFAJRaft and uses a not very popular Slf4j-compatible logging backend (for example, GFLog) then all logging that is produced by that library gets default logger name "com.alipay.sofa.common.log". As result, it is impossible to control logging levels of different parts of the library separately.

Example:

Logger log = LoggerSpaceManager.getLoggerBySpace("someLoggerSpace", "someLoggerName");
// Returns logger with name "com.alipay.sofa.common.log".
// "someLoggerSpace" or "someLoggerName" are not included into the logger name at all

Your scenes

We need to control logging levels for different parts of the app separately because logs from different parts have different importance levels even if there is no logging backend known by sofa-common-tools.

Your advice

I think its necessary to modify MultiAppLoggerSpaceManager.NOP_LOGGER_FACTORY to actually take in account provided logger name instead of just defaulting to a Constants.DEFAULT_LOG:

private static final AbstractLoggerSpaceFactory NOP_LOGGER_FACTORY = new AbstractLoggerSpaceFactory(
            "nop") {
        @Override
        public Logger getLogger(String name) {
            return LoggerFactory.getLogger("com.alipay.sofa.common.log." + name);
        }
    };

Ideally it would be nice to also take the space into the account but for that it would be necessary to modify MultiAppLoggerSpaceManager to create new instances of AbstractLoggerSpaceFactory instead of using single NOP_LOGGER_FACTORY if no pre-defined logging backend is found.

Alternatively, it would be nice to have support of custom logging backend so it would be possible to utilize other logging backends that are not explicitly mentioned in MultiAppLoggerSpaceManager.createILoggerFactory(...)

Environment

  • sofa-common-tools version: 1.0.12 (transitive from jraft-core:1.3.9)
  • JVM version (e.g. java -version): openjdk version "11.0.13"

Add Public Access Modifiers to ExecutingRunnable

Your question

As we all known, ExecutingRunnable is an wrap of Runnable which were used as tracking the running info of submited tasks.
but we can't not access ExecutingRunnable directly due to it's packge level access.

Your scenes

when we making custom excutor extends SofaThreadPoolExecutor or making custom workQueue for the excutor,
we need access to origin Runnable so we can read infomation in our own custom Runnable.

Your advice

Add Public Access Modifiers to ExecutingRunnable

Environment

  • sofa-common-tools version:
  • JVM version (e.g. java -version):
  • OS version (e.g. uname -a):
  • Maven version:
  • IDE version:

Refactor the thread pool module

重构了线程池相关实现,将线程池的监控、配置等能力抽象到了公共类中,以便支持其它类型的线程池

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.