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

Unwanted logging by StatusLogger #3100

Closed
morvael opened this issue Oct 17, 2024 · 12 comments
Closed

Unwanted logging by StatusLogger #3100

morvael opened this issue Oct 17, 2024 · 12 comments
Assignees
Labels

Comments

@morvael
Copy link

morvael commented Oct 17, 2024

Description

I think after the changes in 4e00ea4 I can now observe logging from org.apache.logging.log4j.core.config.AbstractConfiguration ("Starting configuration...", "Start watching for changes to...", etc) which were previously hidden by default. I think that logger used to by WARN by default, now it's INFO by default.

Configuration

Version: 2.24.1

Operating system: Linux Mint 21.3

JDK: Adoptium 21.0.4+7

@morvael
Copy link
Author

morvael commented Oct 17, 2024

The following lines are logged at the start:

Starting configuration XmlConfiguration[location=… , lastModified=…]...
Start watching for changes to … every 0 seconds
Configuration XmlConfiguration[location=… , lastModified=…] started.
Stopping configuration org.apache.logging.log4j.core.config.DefaultConfiguration@…
Configuration org.apache.logging.log4j.core.config.DefaultConfiguration@… stopped.

And these at the end:

Stopping configuration XmlConfiguration[location=… , lastModified=…]...
Configuration XmlConfiguration[location=… , lastModified=…] stopped.

@ppkarwasz
Copy link
Contributor

Hi @morvael,

The default status logger level in version 2.24.1 is still ERROR. Can you check:

  1. If your configuration file does not use the deprecated status attribute.
  2. If you don't define the deprecated Log4jDefaultStatusLevel, log4j2.defaultStatusLevel or LOG4J_DEFAULT_STATUS_LEVEL properties in a property source (Java System properties, environment variables, log4j2.component.properties file).
  3. If you don't define the log4j2.statusLoggerLevel property as Java System property, environment variable or in a log4j2.StatusLogger.properties file.

@ppkarwasz ppkarwasz added waiting-for-user More information is needed from the user and removed waiting-for-maintainer labels Oct 17, 2024
@morvael
Copy link
Author

morvael commented Oct 17, 2024

I will re-verify but I actually tried to use any and all of them to change the log level to WARN and nothing changed, it still printed that INFO.

@github-actions github-actions bot added waiting-for-maintainer and removed waiting-for-user More information is needed from the user labels Oct 17, 2024
@morvael
Copy link
Author

morvael commented Oct 17, 2024

I have no guarantee though that some of the dependencies I use doesn't do one of those things :(

@vy
Copy link
Member

vy commented Oct 29, 2024

@morvael, could you try putting a breakpoint to the StatusLogger.Config#Config() ctor and see where the incorrect level is sourced from, please?

@vy vy added waiting-for-user More information is needed from the user and removed waiting-for-maintainer labels Oct 29, 2024
@morvael
Copy link
Author

morvael commented Oct 30, 2024

Will try. For now this is the stack trace when I get first log line:
image

@github-actions github-actions bot added waiting-for-maintainer and removed waiting-for-user More information is needed from the user labels Oct 30, 2024
@morvael
Copy link
Author

morvael commented Oct 30, 2024

This is the config stack trace:
image

@morvael
Copy link
Author

morvael commented Oct 30, 2024

private static Map<String, Object> normalizeProperties(Properties... propertiesList) {
returns empty map, so no relevant properties were detected I guess.
image

image

@morvael
Copy link
Author

morvael commented Oct 30, 2024

Ok, it seems I'm going through that code twice actually. And in the second one I'm doing code-based rebuild of configuration to configure some stuff in the code (this is for test programs) like in the old log4j. And I have the line there:
builder.setStatusLevel(Level.INFO);
...so the funny thing is it must have not worked the same in old versions as it works now, because it didn't log those messages.

So I think we can close the issue, though I still don't know why now and not before.

@morvael
Copy link
Author

morvael commented Oct 30, 2024

Sorry for false report.

@morvael morvael closed this as completed Oct 30, 2024
@morvael
Copy link
Author

morvael commented Oct 30, 2024

Perhaps in the old version StatusLogger wasn't rebuilt.

@vy vy self-assigned this Oct 30, 2024
@ppkarwasz
Copy link
Contributor

@morvael,

Ok, it seems I'm going through that code twice actually. And in the second one I'm doing code-based rebuild of configuration to configure some stuff in the code (this is for test programs) like in the old log4j. And I have the line there: builder.setStatusLevel(Level.INFO); ...so the funny thing is it must have not worked the same in old versions as it works now, because it didn't log those messages.

That is easy to explain: I increased the level of those lifecycle messages in #3043 to make them more useful. The start and stop events of a LoggerContext and Configuration are pretty rare, but are very important to debug problems such as continuous reconfiguration.
This is part of a continuous effort to improve our own logging statements according to our log level semantic.
The meaning of status logger levels should signify:

  • ERROR: these are errors that users should immediately resolve.
  • WARN: these are potential problems that the system detected (e.g. the presence of an unrecognized property in the configuration file) and users should be able to remove those warnings (currently it is not always possible, which is a blocker for Issue 1501: increase default StatusLogger level to warn #1592).
  • INFO: these are noteworthy events (e.g. reconfiguration, file rollover) that the system does not consider problems, but might help diagnosing problems.

Sorry for false report.

No problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants