-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-6305][CORE][TEST][FOLLOWUP] Add LoggingSuite and some improvements #34965
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
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
47cffb9
Add LoggingSuite and some improvements.
viirya 0ac57d6
Copy log event first.
viirya 7067976
For hive thriftserver
viirya 96c870c
Update UISeleniumSuite
viirya 452515e
Set console filter to warn
viirya f4781b2
Correct filename for file appender.
viirya b2ea58b
Fix k8s integration test properties
viirya 444b405
Move log4j properties
viirya 374669e
Remove log4j 1.x properties file
viirya f6fee0f
Fix K8S tests.
viirya eb3e224
Merge remote-tracking branch 'upstream/master' into log4j2_improvement
viirya 2efd418
Remove unused import.
viirya d951d5d
Only let Spark log debug.
viirya fb33ef4
Fix a few places using "log4j.properties"
viirya 8d79c65
Trigger Build
viirya bd5ef16
Update R test script.
viirya 371f27e
Upload all log4j2 configuration files.
viirya 2c233c9
For review comment.
viirya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 0 additions & 43 deletions
43
core/src/main/resources/org/apache/spark/log4j-defaults.properties
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
core/src/test/scala/org/apache/spark/internal/LoggingSuite.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.internal | ||
|
|
||
| import org.apache.logging.log4j.{Level, LogManager} | ||
| import org.apache.logging.log4j.core.{Filter, Logger} | ||
| import org.apache.logging.log4j.core.impl.Log4jLogEvent.Builder | ||
| import org.apache.logging.log4j.message.SimpleMessage | ||
|
|
||
| import org.apache.spark.SparkFunSuite | ||
| import org.apache.spark.internal.Logging.SparkShellLoggingFilter | ||
| import org.apache.spark.util.Utils | ||
|
|
||
| class LoggingSuite extends SparkFunSuite { | ||
|
|
||
| test("spark-shell logging filter") { | ||
| val ssf = new SparkShellLoggingFilter() | ||
| val rootLogger = LogManager.getRootLogger().asInstanceOf[Logger] | ||
| val originalLevel = rootLogger.getLevel() | ||
| rootLogger.setLevel(Level.INFO) | ||
| val originalThreshold = Logging.sparkShellThresholdLevel | ||
| Logging.sparkShellThresholdLevel = Level.WARN | ||
| try { | ||
| val logger1 = LogManager.getLogger("a.b.c.D") | ||
| .asInstanceOf[Logger] | ||
| val logEvent1 = new Builder().setLevel(Level.INFO) | ||
| .setLoggerName(logger1.getName()).setMessage(new SimpleMessage("Test")).build() | ||
| // Logger's default level is not null in log4j2, and cannot be set to null too. | ||
| assert(ssf.filter(logEvent1) == Filter.Result.NEUTRAL) | ||
|
|
||
| // custom log level configured | ||
| val parentLogger = LogManager.getLogger("a.b.c") | ||
| .asInstanceOf[Logger] | ||
| parentLogger.setLevel(Level.INFO) | ||
| assert(ssf.filter(logEvent1) == Filter.Result.NEUTRAL) | ||
|
|
||
| // log level is greater than or equal to threshold level | ||
| val logger2 = LogManager.getLogger("a.b.E") | ||
| .asInstanceOf[Logger] | ||
| val logEvent2 = new Builder().setLevel(Level.INFO) | ||
| .setLoggerName(logger2.getName()).setMessage(new SimpleMessage("Test")).build() | ||
| Utils.setLogLevel(Level.INFO) | ||
| assert(ssf.filter(logEvent2) != Filter.Result.DENY) | ||
| } finally { | ||
| rootLogger.setLevel(originalLevel) | ||
| Logging.sparkShellThresholdLevel = originalThreshold | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This seems not work with log4j 2.x. So for K8S decommission integration tests which check logs, I updated the test code to set up a log4j2.properties.