Flink 本地运行日志配置

  1. 方法一: 使用 log4j.properties

    在 src/main/resources 中添加 log4j.properties 文件

    ################################################################################
    #  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.
    ################################################################################
    
    # This affects logging for both user code and Flink
    log4j.rootLogger=INFO, console
    
    # Uncomment this if you want to _only_ change Flink's logging
    log4j.logger.org.apache.flink=WARN
    
    # The following lines keep the log level of common libraries/connectors on
    # log level INFO. The root logger does not override this. You have to manually
    # change the log levels here.
    log4j.logger.akka=WARN
    log4j.logger.org.apache.kafka=INFO
    log4j.logger.org.apache.hadoop=WARN
    log4j.logger.org.apache.zookeeper=WARN
    
    # Log all infos to the console
    log4j.appender.console=org.apache.log4j.ConsoleAppender
    log4j.appender.console.layout=org.apache.log4j.PatternLayout
    log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %-60c %x - %m%n
    
    # Suppress the irrelevant (wrong) warnings from the Netty channel handler
    log4j.logger.org.apache.flink.shaded.akka.org.jboss.netty.channel.DefaultChannelPipeline=ERROR, console
    
  2. 方法二: 使用 logback.xml

    在 src/main/resources 中添加 logback.xml 文件

    
    
    
        
        
            
    
                ${CONSOLE_LOG_PATTERN}
                
                UTF-8
            
        
    
        
        
            
        
    
        
        
        
        
    
        
        
            
        
        
            
        
        
            
        
        
            
        
    
        
        
            
        
    
    

    修改 pom.xml 配置
    在引入flink相关依赖之前引入logback相关依赖,如下

    ...
    
      UTF-8
      UTF-8
      1.9.2
      3.0.0-cdh6.3.2-9.0
      1.2.3
      1.7.30
      compile
    
    ...
    
      
          ch.qos.logback
          logback-core
          ${logback.version}
      
      
          ch.qos.logback
          logback-access
          ${logback.version}
      
      
          ch.qos.logback
          logback-classic
          ${logback.version}
      
      
          org.slf4j
          log4j-over-slf4j
          ${log4j-over-slf4j.version}
      
      
          org.apache.flink
          flink-scala_${scala.binary.version}
          ${flink.version}
          ${scope.level}
      
      ...
    
    

你可能感兴趣的:(Flink 本地运行日志配置)