-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Set root logger level for CLIs #123742
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
Set root logger level for CLIs #123742
Conversation
All CLIs in elasticsearch support command line flags for controlling the output level. When --silent is used, the expectation is that normal logging is omitted. Yet the log4j logger is still configured to output error level logs. This commit sets the appropriate log level for log4j depending on the Terminal log level.
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
|
Note to reviewers: I had wanted to change the console logger to output to stderr. Unfortunately that is difficult given our current LogConfigurator. We should still do that in the future, but this seemed a reasonable stopgap since the levels between Terminal and log4j should match. Testing was also difficult, we don't really have many tests at this level. I tested manually by running a tool locally that had a log4j error message added artificially. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
The test failure could be real. |
|
I think @prdoyle is right, I've tried fixing the packaging tests this way initially. However the "is ready" check for ES in the packaging tests depends on some info logs. |
|
I believe the test failure was because CLI tests would not restore the level, so if eg silent was tested with a cli test, logging in later tests was borked. I've tweaked this to capture and restore the log level in all CLI tests. |
|
|
||
| @Before | ||
| public void resetTerminal() throws IOException { | ||
| capturedLogLevel = LoggerFactory.provider().getRootLevel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've bitten ourselves before by tests doing this and then all subsequent tests create insane amounts of log output causing all kinds of havoc. Is there any reason not to do this in ESTestCase so that we catch all these scenarios?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable. I pushed 2a9144a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to relax this a little bit. For some reason, capturing and restoring per-test in ESTestCase causes several tests which test logging to fail, seemingly because they don't get the expected log levels. So I changed this to be at the suite level for now.
All CLIs in elasticsearch support command line flags for controlling the output level. When --silent is used, the expectation is that normal logging is omitted. Yet the log4j logger is still configured to output error level logs. This commit sets the appropriate log level for log4j depending on the Terminal log level.
All CLIs in elasticsearch support command line flags for controlling the output level. When --silent is used, the expectation is that normal logging is omitted. Yet the log4j logger is still configured to output error level logs. This commit sets the appropriate log level for log4j depending on the Terminal log level.
All CLIs in elasticsearch support command line flags for controlling the output level. When --silent is used, the expectation is that normal logging is omitted. Yet the log4j logger is still configured to output error level logs. This commit sets the appropriate log level for log4j depending on the Terminal log level.
All CLIs in elasticsearch support command line flags for controlling the output level. When --silent is used, the expectation is that normal logging is omitted. Yet the log4j logger is still configured to output error level logs. This commit sets the appropriate log level for log4j depending on the Terminal log level.
All CLIs in elasticsearch support command line flags for controlling the output level. When --silent is used, the expectation is that normal logging is omitted. Yet the log4j logger is still configured to output error level logs. This commit sets the appropriate log level for log4j depending on the Terminal log level.
All CLIs in elasticsearch support command line flags for controlling the output level. When --silent is used, the expectation is that normal logging is omitted. Yet the log4j logger is still configured to output error level logs. This commit sets the appropriate log level for log4j depending on the Terminal log level. Co-authored-by: Lorenzo Dematté <[email protected]>
All CLIs in elasticsearch support command line flags for controlling the output level. When --silent is used, the expectation is that normal logging is omitted. Yet the log4j logger is still configured to output error level logs. This commit sets the appropriate log level for log4j depending on the Terminal log level.