2017-09-19 71 views
0

我正在開發一個PySpark應用程序,我將其部署爲yarn-cluster模式。我已經給stdout作爲日誌流處理程序。我可以看到YARN UI中的日誌。但是,我無法在/ var/log/sparkapp/yarn下找到stdout日誌。我在那裏只看到stderr日誌。這可能是什麼原因?無法找到PySpark標準輸出日誌

這是在應用程序日誌我的一部分

import logging 
import sys 

logger = logging.getLogger(__name__) 
logger.setLevel(logging.INFO) 
lsh = logging.StreamHandler(sys.stdout) 
lsh.setLevel(logging.INFO) 
lformat = logging.Formatter(fmt='%(asctime)s.%(msecs)03d %(levelname)s :%(name)s - %(message)s', datefmt='%m/%d/%Y %I:%M:%S') 
lsh.setFormatter(lformat) 
logger.addHandler(lsh) 

log4j.properties

log4jspark.root.logger=INFO,console 
log4jspark.log.dir=. 
log4jspark.log.file=spark.log 
log4jspark.log.maxfilesize=1024MB 
log4jspark.log.maxbackupindex=10 

# Define the root logger to the system property "spark.root.logger". 
log4j.rootLogger=${log4jspark.root.logger}, EventCounter 

# Set everything to be logged to the 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 
log4j.appender.console.Threshold=INFO 

# Settings to quiet third party logs that are too verbose 
log4j.logger.org.eclipse.jetty=WARN 
log4j.logger.org.eclipse.jetty.util.component.AbstractLifeCycle=ERROR 
log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=INFO 
log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=INFO 

回答

0

試試這個得到記錄器爲您的火花的工作:

log4jLogger = sc._jvm.org.apache.log4j 
logger = log4jLogger.LogManager.getLogger(__name__) 

您可以修改log4j.properties更改target文件:

log4j.appender.console.target=System.out 
相關問題