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

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

Open
ldcsaa opened this issue Aug 3, 2023 · 3 comments · May be fixed by #3221
Open

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

ldcsaa opened this issue Aug 3, 2023 · 3 comments · May be fixed by #3221
Assignees
Labels
area/logging Issues or PRs related to logging of Sentinel good first issue Good for newcomers kind/bug Category issues or prs related to bug.
Milestone

Comments

@ldcsaa
Copy link

ldcsaa commented Aug 3, 2023

加载错误的 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);
    }
@sczyh30
Copy link
Member

sczyh30 commented Aug 3, 2023

Would you like to contribute a PR to improve it?

@sczyh30 sczyh30 added the area/logging Issues or PRs related to logging of Sentinel label Aug 3, 2023
@sczyh30 sczyh30 added kind/bug Category issues or prs related to bug. good first issue Good for newcomers labels Aug 16, 2023
@sczyh30 sczyh30 added this to the v2.0.0 milestone Aug 16, 2023
liuweiGit added a commit to liuweiGit/Sentinel that referenced this issue Sep 7, 2023
@sunwei-nj
Copy link

我想改一下试试,直接拉一个版本提交就行了吗?

@sunwei-nj
Copy link

这个BUG已经改好了,我想认领一个BUG改一下。

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 good first issue Good for newcomers kind/bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants