Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuring csp.sentinel.log.dir through the configuration file does not work #812

Closed
threedr3am opened this issue Jun 5, 2019 · 4 comments
Labels
area/logging Issues or PRs related to logging of Sentinel kind/question Category issues related to questions or problems

Comments

@threedr3am
Copy link

Issue Description

Type: bug report or feature request

Describe what happened (or what feature you want)

当我根据wiki文档使用${user_home}/logs/csp/${project.name}.properties配置文件的方式配置csp.sentinel.log.dir时,该配置不会生效。

Describe what you expected to happen

首先,可以看到SentinelConfig这个class的源码,在类被加载后执行static代码块的时候,会执行com/alibaba/csp/sentinel/config/SentinelConfig.java:65处对,配置文件和jvm参数中的配置读取,并且设置进com.alibaba.csp.sentinel.config.SentinelConfig#props中,但是注意com/alibaba/csp/sentinel/config/SentinelConfig.java:109获取配置文件的fileName时,是调用com.alibaba.csp.sentinel.log.LogBase#getLogBaseDir获取配置文件的目录,而查看类LogBase在执行static代码块的时候,会执行com.alibaba.csp.sentinel.log.LogBase#init,其中com.alibaba.csp.sentinel.log.LogBase#logBaseDir的值只会使用两种方式得到:

String logDir = System.getProperty(LOG_DIR);

 if (logDir == null || logDir.isEmpty()) {
       logDir = System.getProperty(USER_HOME);
       logDir = addSeparator(logDir) + DIR_NAME + File.separator;
 }

所以,该配置必然不会生效,所以,在com.alibaba.csp.sentinel.config.SentinelConfig#loadProps中直接调用LogBase.getLogBaseDir()获取log dir必然是有问题的。

How to reproduce it (as minimally and precisely as possible)

  1. 使用${user_home}/logs/csp/${project.name}.properties配置文件的方式配置csp.sentinel.log.dir
  2. 启动项目
  3. 观察日志输出目录,还是默认的${user_home}/logs/csp/

Tell us your environment

最新master(2019-06-05)

Anything else we need to know?

@sentinel-bot
Copy link
Collaborator

Hi @threedr3am, we detect non-English characters in the issue. This comment is an auto translation from @sentinel-bot to help other users to understand this issue.
We encourage you to describe your issue in English which is more friendly to other users.

Configuring csp.sentinel.log.dir through the configuration file does not work

Issue Description

Type: bug report or feature request

Describe what happened (or what feature you want)

When I am based on [wiki documentation] (https://github.com/alibaba/Sentinel/wiki/%E5%90%AF%E5%8A%A8%E9%85%8D%E7%BD%AE%E9%A1 %B9) When csp.sentinel.log.dir is configured using the ${user_home}/logs/csp/${project.name}.properties configuration file, the configuration will not take effect.

Describe what you expected to happen

First, you can see the source code of the SentinelConfig class. When the static code block is executed after the class is loaded, it will execute com/alibaba/csp/sentinel/config/SentinelConfig.java:65, the configuration file and the jvm parameter. The configuration in the read is set and entered in com.alibaba.csp.sentinel.config.SentinelConfig#props, but note that com/alibaba/csp/sentinel/config/SentinelConfig.java:109 gets the fileName of the configuration file When you call com.alibaba.csp.sentinel.log.LogBase#getLogBaseDir to get the configuration file directory, the view class LogBase executes com.alibaba.csp.sentinel.log when executing the static code block. LogBase#init, where the value of com.alibaba.csp.sentinel.log.LogBase#logBaseDir is only available in two ways:

String logDir = System.getProperty(LOG_DIR);

 if (logDir == null || logDir.isEmpty()) {
       logDir = System.getProperty(USER_HOME);
       logDir = addSeparator(logDir) + DIR_NAME + File.separator;
 }

Therefore, the configuration will not take effect, so calling LogBase.getLogBaseDir() directly in com.alibaba.csp.sentinel.config.SentinelConfig#loadProps to get the log dir is definitely a problem.

How to reproduce it (as minimally and precisely as possible)

  1. Configure csp.sentinel.log.dir using the ${user_home}/logs/csp/${project.name}.properties configuration file.
  2. Start the project
  3. Observe the log output directory, or the default ${user_home}/logs/csp/

Tell us your environment

The latest master (2019-06-05)

Anything else we need to know?

@sentinel-bot sentinel-bot changed the title 通过配置文件配置csp.sentinel.log.dir不起作用 Configuring csp.sentinel.log.dir through the configuration file does not work Jun 5, 2019
@sczyh30 sczyh30 added area/logging Issues or PRs related to logging of Sentinel kind/question Category issues related to questions or problems labels Jun 5, 2019
@sczyh30
Copy link
Member

sczyh30 commented Jun 5, 2019

Hi,目前 ${user_home}/logs/csp/${project.name}.properties 方式暂时不支持配置日志目录,可以先采用 JVM -D 参数形式配置。未来会增强 properties 文件方式配置的支持,可以参考 #804


It's not supported to configure the log directory via ${user_home}/logs/csp/${project.name}.properties file till now.

@threedr3am
Copy link
Author

👌,我看wiki文档可以update一下,上面描述只是project.name不支持。

@sczyh30
Copy link
Member

sczyh30 commented Jun 5, 2019

👌,我看wiki文档可以update一下,上面描述只是project.name不支持。

Thanks for your suggestion. I've updated the wiki document :)

@sczyh30 sczyh30 closed this as completed Jun 5, 2019
CST11021 pushed a commit to CST11021/Sentinel that referenced this issue Nov 3, 2021
[RIP-9]Add English docs of architecture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/logging Issues or PRs related to logging of Sentinel kind/question Category issues related to questions or problems
Projects
None yet
Development

No branches or pull requests

3 participants