forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-6305][CORE][TEST][FOLLOWUP] Add LoggingSuite and some improvem…
…ents ### What changes were proposed in this pull request? This patch proposes to add `LoggingSuite` back and also does some other improvements. In summary: 1. Add `LoggingSuite` back 2. Refactor logging related change based on community suggestion, e.g. let `SparkShellLoggingFilter` inherit from `AbstractFilter` instead of `Filter`. 3. Fix maven test failures for hive-thriftserver module 4. Fix K8S decommision integration tests which check log output 5. A few places in code/doc which refer/mention log4j.properties ### Why are the changes needed? `LoggingSuite` was wrongly removed in previous PR. We should add it back. There are a few places we can also simplify the code. A few places in code which programmingly write out log4j properties files are also changed to log4j2 here. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass all tests. Closes apache#34965 from viirya/log4j2_improvement. Authored-by: Liang-Chi Hsieh <[email protected]> Signed-off-by: Liang-Chi Hsieh <[email protected]>
- Loading branch information
Showing
17 changed files
with
324 additions
and
328 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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.