Skip to content

Commit

Permalink
Add log4j-spark-container.properties and support SPARK_LOG4J_CONF
Browse files Browse the repository at this point in the history
  • Loading branch information
sryza committed Apr 7, 2014
1 parent e74450b commit 10934b8
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 15 deletions.
11 changes: 11 additions & 0 deletions yarn/alpha/src/main/resources/log4j-spark-container.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Set everything to be logged to the console
log4j.rootCategory=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n

# Settings to quiet third party logs that are too verbose
log4j.logger.org.eclipse.jetty=WARN
log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=INFO
log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=INFO
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class ExecutorRunnable(
credentials.writeTokenStorageToStream(dob)
ctx.setContainerTokens(ByteBuffer.wrap(dob.getData()))

val commands = prepareCommand(masterAddress, slaveId, hostname, executorMemory, executorCores)
val commands = prepareCommand(masterAddress, slaveId, hostname, executorMemory, executorCores,
localResources.contains(ClientBase.LOG4J_PROP))
logInfo("Setting up executor with commands: " + commands)
ctx.setCommands(commands)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ trait ClientBase extends Logging {
localResources: HashMap[String, LocalResource],
stagingDir: String): HashMap[String, String] = {
logInfo("Setting up the launch environment")
val log4jConfLocalRes = localResources.getOrElse(ClientBase.LOG4J_PROP, null)

val env = new HashMap[String, String]()

ClientBase.populateClasspath(yarnConf, sparkConf, log4jConfLocalRes != null, env)
ClientBase.populateClasspath(yarnConf, sparkConf, localResources.contains(ClientBase.LOG4J_PROP),
env)
env("SPARK_YARN_MODE") = "true"
env("SPARK_YARN_STAGING_DIR") = stagingDir
env("SPARK_USER") = UserGroupInformation.getCurrentUser().getShortUserName()
Expand Down Expand Up @@ -344,7 +344,9 @@ trait ClientBase extends Logging {
JAVA_OPTS += " " + env("SPARK_JAVA_OPTS")
}

JAVA_OPTS += " " + YarnSparkHadoopUtil.getLoggingArgsForContainerCommandLine()
if (!localResources.contains(ClientBase.LOG4J_PROP)) {
JAVA_OPTS += " " + YarnSparkHadoopUtil.getLoggingArgsForContainerCommandLine()
}

// Command for the ApplicationMaster
val commands = List[String](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ trait ExecutorRunnableUtil extends Logging {
slaveId: String,
hostname: String,
executorMemory: Int,
executorCores: Int) = {
executorCores: Int,
userSpecifiedLogFile: Boolean) = {
// Extra options for the JVM
var JAVA_OPTS = ""
// Set the JVM memory
Expand All @@ -62,7 +63,10 @@ trait ExecutorRunnableUtil extends Logging {

JAVA_OPTS += " -Djava.io.tmpdir=" +
new Path(Environment.PWD.$(), YarnConfiguration.DEFAULT_CONTAINER_TEMP_DIR) + " "
JAVA_OPTS += YarnSparkHadoopUtil.getLoggingArgsForContainerCommandLine() + " "

if (!userSpecifiedLogFile) {
JAVA_OPTS += " " + YarnSparkHadoopUtil.getLoggingArgsForContainerCommandLine()
}

// Commenting it out for now - so that people can refer to the properties if required. Remove
// it once cpuset version is pushed out.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ class YarnSparkHadoopUtil extends SparkHadoopUtil {

object YarnSparkHadoopUtil {
def getLoggingArgsForContainerCommandLine(): String = {
"-Dlog4j.configuration=container-log4j.properties " +
"-Dhadoop.root.logger=INFO,CLA " +
// for yarn/stable:
"-Dyarn.app.container.log.filesize=0 " +
"-Dyarn.app.container.log.dir=" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + " " +
// for yarn/alpha:
"-Dyarn.app.mapreduce.container.log.dir=" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + " " +
"-Dyarn.app.mapreduce.container.log.filesize=0"
"-Dlog4j.configuration=log4j-spark-container.properties"
}
}
11 changes: 11 additions & 0 deletions yarn/stable/src/main/resources/log4j-spark-container.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Set everything to be logged to the console
log4j.rootCategory=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n

# Settings to quiet third party logs that are too verbose
log4j.logger.org.eclipse.jetty=WARN
log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=INFO
log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=INFO
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class ExecutorRunnable(
credentials.writeTokenStorageToStream(dob)
ctx.setTokens(ByteBuffer.wrap(dob.getData()))

val commands = prepareCommand(masterAddress, slaveId, hostname, executorMemory, executorCores)
val commands = prepareCommand(masterAddress, slaveId, hostname, executorMemory, executorCores,
localResources.contains(ClientBase.LOG4J_PROP))

logInfo("Setting up executor with commands: " + commands)
ctx.setCommands(commands)
Expand Down

0 comments on commit 10934b8

Please sign in to comment.