Spark on Yarn 自定义日志打印及级别

本文介绍了如何在Spark on YARN环境中自定义日志打印及级别,包括配置自定义日志文件、代码中的日志设置、任务提交时的日志配置,以及如何查看和调整日志级别,旨在实现业务日志与Spark日志的分离,便于问题排查。
摘要由CSDN通过智能技术生成

spark 自定义日志打印及级别

在处理spark任务的时候,我们需要经常查看日志,那么日志的级别对我们来说就很重要。但有时候,我们还需要输出一些业务日志,那它就会被spark的大量日志给覆盖掉,但调日志级别,又会使查找问题变的比较困难,今天,我们来解决下这个问题。

日志打印定义

我们首先需要日志配置文件,并在任务提交的脚本中设置成我们自定义的日志文件。这里将分别对两种日志进行配置对比,分别是java自带日志和spark内部日志。

1. 自定义日志文件 ,也可以将spark配置文件中的log4j文件拷贝下并做修改。

# 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.
#

# Set everything to be logged to the console
# DEBUG,INFO,WARN,FATAL,ERROR
log4j.rootLogger=INFO, console
#log4j.rootCategory=INFO
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.logger.javaLog=WARN, javaLog
#log4j.logger.javaLog.access=WARN
log4j.appender.javaLog.errorhandler.root-ref=false
log4j.appender.javaLog=org.apache.log4j.ConsoleAppender
log4j.appender.javaLog.target
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值