-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-30167][REPL] Log4j configuration for REPL can't override the root logger properly. #26798
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
Conversation
|
Test build #114993 has finished for PR 26798 at commit
|
|
cc @ankuriitg and @vanzin |
| val infoLogMessage2 = "infoLogMessage3 should be output" | ||
|
|
||
| val out = try { | ||
| PropertyConfigurator.configure(log4jprops.toString) |
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.
.getAbsolutePath()
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.
Thanks. I've replaced it with absolute path.
Make config-file-path-string absolute path
28531a3 to
df78a35
Compare
|
Test build #115284 has finished for PR 26798 at commit
|
|
retest this please. |
|
Test build #115287 has finished for PR 26798 at commit
|
|
Ok, I got what was wrong before (and with the previous unit test). Merging to master. |
What changes were proposed in this pull request?
In the current implementation of
SparkShellLoggingFilter, if the log level of the root logger and the log level of a message are different, whether a message should logged is decided based on log4j's configuration but whether the message should be output to the REPL's console is not cared.So, if the log level of the root logger is
DEBUG, the log level of REPL's logger isWARNand the log level of a message isINFO, the message will output to the REPL's console even thoughINFO < WARN.https://github.com/apache/spark/pull/26798/files#diff-bfd5810d8aa78ad90150e806d830bb78L237
The ideal behavior should be like as follows and implemented them in this change.
If the log level of a message is greater than or equal to the log level of the root logger, the message should be logged but whether the message is output to the REPL's console should be decided based on whether the log level of the message is greater than or equal to the log level of the REPL's logger.
If a log level or custom appenders are explicitly defined for a category, whether a log message via the logger corresponding to the category is logged and output to the REPL's console should be decided baed on the log level of the category.
We can confirm whether a log level or appenders are explicitly set to a logger for a category by
Logger#getLevelandLogger#getAllAppenders.hasMoreElements.Why are the changes needed?
This is a bug breaking a compatibility.
#9816 enabled REPL's log4j configuration to override root logger but #23675 seems to have broken the feature.
You can see one example when you modifies the default log4j configuration like as follows.
If you launch REPL with the configuration, INFO level logs appear even though the log level for REPL is WARN.
Before #23675 was applied, those INFO level logs are not shown with the same log4j.properties.
Does this PR introduce any user-facing change?
Yes. The logging behavior for REPL is fixed.
How was this patch tested?
Manual test and newly added unit test.