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

[SHIRO-820] - Fix Log4j2 logs format #1193

Merged
merged 1 commit into from
Dec 23, 2023

Conversation

ksilisk
Copy link

@ksilisk ksilisk commented Dec 2, 2023

When using the utility, I noticed that the logs were displayed incorrectly.
I found a similar problem in Jira, but I think the [INFO ] output is correct, but the space after it is a consequence of incorrect logger settings, which I corrected.
Also update log message.

JIRA issue https://issues.apache.org/jira/browse/SHIRO-820

Following this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [SHIRO-XXX] - Fixes bug in SessionManager,
    where you replace SHIRO-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn verify to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If you have a group of commits related to the same change, please squash your commits into one and force push your branch using git rebase -i.
  • Committers: Make sure a milestone is set on the PR

Trivial changes like typos do not require a GitHub issue (javadoc, comments...).
In this case, just format the pull request title like [DOC] - Add javadoc in SessionManager.

If this is your first contribution, you have to read the Contribution Guidelines

If your pull request is about ~20 lines of code you don't need to sign an Individual Contributor License Agreement
if you are unsure please ask on the developers list.

To make clear that you license your contribution under the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@lprimak lprimak added shiro-2.0.0 java Pull requests that update Java code CLA core Core Modules labels Dec 2, 2023
@lprimak lprimak added this to the 2.0 milestone Dec 2, 2023
Copy link
Contributor

@bmarwell bmarwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. looking at this, the old hasher CLI tool just gave the hash as the output. Now, we get an additional [INFO ] prefix. For parsing, leaving out the prefix would be beneficial.

Then, the -5level is probably to align output nicely:

[DEBUG] message
[INFO ] hash: …
[WARN ] a warning
[ERROR] an error

That said, I'd prefer to rather change the pattern in log4j.xml to just %msg%n for compatibility and leave the LOG.info statement as-is for easier parsing. Interesting. looking at this, the old hasher CLI tool just gave the hash as the output. Now, we get an additional [INFO ] prefix. For parsing, leaving out the prefix would be beneficial.

Then, the -5level is probably to align output nicely:

[DEBUG] message
[INFO ] hash: …
[WARN ] a warning
[ERROR] an error

That said, I'd prefer to rather change the pattern in log4j.xml to just %msg%n for compatibility and leave the LOG.info statement as-is for easier parsing.

@ksilisk
Copy link
Author

ksilisk commented Dec 3, 2023

Interesting. looking at this, the old hasher CLI tool just gave the hash as the output. Now, we get an additional [INFO ] prefix. For parsing, leaving out the prefix would be beneficial.

Then, the -5level is probably to align output nicely:

[DEBUG] message
[INFO ] hash: …
[WARN ] a warning
[ERROR] an error

That said, I'd prefer to rather change the pattern in log4j.xml to just %msg%n for compatibility and leave the LOG.info statement as-is for easier parsing. Interesting. looking at this, the old hasher CLI tool just gave the hash as the output. Now, we get an additional [INFO ] prefix. For parsing, leaving out the prefix would be beneficial.

Then, the -5level is probably to align output nicely:

[DEBUG] message
[INFO ] hash: …
[WARN ] a warning
[ERROR] an error

That said, I'd prefer to rather change the pattern in log4j.xml to just %msg%n for compatibility and leave the LOG.info statement as-is for easier parsing.

Thanks for the answer @bmarwell!

No, before this the hash output looked like this

[INFO ] some_hash

In my opinion, the presence of a prefix is actually not correct, as was described in the SHIRO-820 issue.

I think that the best solution would be to display the hash in System.out without any prefix.
Then that will solve SHIRO-820.

In this case, there is no need to change the log4j2.xml
Just change LOG.info to System.out.println

If you agree with my decision, I'm ready to correct it.

@lprimak
Copy link
Contributor

lprimak commented Dec 23, 2023

fixed as per @bmarwell

@lprimak lprimak dismissed bmarwell’s stale review December 23, 2023 04:00

fixed as per Benjamin's changes

@lprimak lprimak merged commit 2e8de38 into apache:main Dec 23, 2023
21 of 22 checks passed
@lprimak
Copy link
Contributor

lprimak commented Dec 23, 2023

Thank you @ksilisk for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA core Core Modules java Pull requests that update Java code shiro-2.0.0
3 participants