alibaba / alibaba/Sentinel

[BUG] com.alibaba.csp.sentinel.log.LogBase#loadProperties() 日志输出bug

Open
#3,192 3 comments 0 reactions 1 assignee Claimed by @LearningGp View on GitHub
area/logging good first issue kind/bug
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

加载错误的 logLevelString 时,以下代码会输出令人费解的日志:`
Log level : INFO is invalid. Use default : INFO`,应该把 ` System.out.println("Log level : " + logLevel + " is invalid. Use default : " + LOG_DEFAULT_LEVEL.toString());` 改为 ` System.out.println("Log level : " + logLevelString+ " is invalid. Use default : " + LOG_DEFAULT_LEVEL.toString());`

```
private static void loadProperties() {
Properties properties = LogConfigLoader.getProperties();

logOutputType = properties.get(LOG_OUTPUT_TYPE) == null ? logOutputType : properties.getProperty(LOG_OUTPUT_TYPE);
if (!LOG_OUTPUT_TYPE_FILE.equalsIgnoreCase(logOutputType) && !LOG_OUTPUT_TYPE_CONSOLE.equalsIgnoreCase(logOutputType)) {
logOutputType = LOG_OUTPUT_TYPE_FILE;
}
System.out.println("INFO: Sentinel log output type is: " + logOutputType);

logCharSet = properties.getProperty(LOG_CHARSET) == null ? logCharSet : properties.getProperty(LOG_CHARSET);
System.out.println("INFO: Sentinel log charset is: " + logCharSet);

logBaseDir = properties.getProperty(LOG_DIR) == null ? logBaseDir : properties.getProperty(LOG_DIR);
logBaseDir = addSeparator(logBaseDir);
File dir = new File(logBaseDir);
if (!dir.exists()) {
if (!dir.mkdirs()) {
System.err.println("ERROR: create Sentinel log base directory error: " + logBaseDir);
}
}
System.out.println("INFO: Sentinel log base directory is: " + logBaseDir);

String usePid = properties.getProperty(LOG_NAME_USE_PID);
logNameUsePid = "true".equalsIgnoreCase(usePid);
System.out.println("INFO: Sentinel log name use pid is: " + logNameUsePid);

String logLevelString = properties.getProperty(LOG_LEVEL);
if (logLevelString != null && (logLevelString = logLevelString.trim()).length() > 0) {
try {
logLevel = Level.parse(logLevelString);
} catch (IllegalArgumentException e) {
// 此处不应该用 logLevel ,而应该用 logLevelString
System.out.println("Log level : " + logLevel + " is invalid. Use default : " + LOG_DEFAULT_LEVEL.toString());
}
}
System.out.println("INFO: Sentinel log level is: " + logLevel);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.