Tencent / TubeMQ

TubeMQ has been donated to the Apache Software Foundation and renamed to InLong, please visit the new Apache repository: https://github.com/apache/incubator-inlong
https://inlong.apache.org/
2.02k stars 388 forks source link

tubemq-server模块和tubemq-example模块下缺少打印到控制台的日志配置 #46

Closed klboke closed 5 years ago

klboke commented 5 years ago

Motivation 系统日志框架使用的log4j,tubemq-server模块和tubemq-example模块下都没有log4j配置,开发调试时没有打印到控制台的日志非常不方便。当然这个不影响打包后的程序日志

(optional) Design 在tubemq-server模块和tubemq-example模块下新增log4j.properties的配置文件,配置日志打印到控制台 (optional) Example snippet 如:

log4j.rootLogger = info,stdout

log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
tisonkun commented 5 years ago

Thanks for your proposal. I think it is valid and helps on developing.

Two suggestions here.

  1. Always include LICENSE header in new files.
  2. Maybe it is better to set default to
log4j.rootLogger=OFF, stdout

and only turn on log locally for debugging.

gosonzhang commented 5 years ago

see https://github.com/Tencent/TubeMQ/pull/47 discusses

klboke commented 5 years ago

I know that the log configuration under conf can be loaded by -Dlog4j.configuration, but this does not solve my problem. At first, I did this. Then I found that the configuration log under conf was not printed to the console, but was written to the specified file. I think in development mode, I don’t expect to go to the log file every time. Looking for log information, it is more desirable to see the information directly from the console, however, I want to complete this, but also a lot of effort to modify the log configuration, this is not what I want


我知道通过-Dlog4j.configuration的方式可以加载到conf下的日志配置,但是这并没解决我的问题。一开始我确实是这么做的,然后我发现conf下的配置日志都没有打印到控制台,而是写入到指定的文件了,我想在开发模式下,一定不期望每次都去日志文件中找日志信息吧,更期望的是直接从控制台中看到信息,然而,我想完成这个,还的费很大的劲去修改日志配置,这不是我想要的