• Kafka源码工程examples项目配置log4j


    examples项目启动想知道有哪些错误,通过日志了解代码执行逻辑,但是启动SimpleConsumerDemo了报错如下:

    log4j.proproties也配置了

    log4j.proproties配置如下:

    # 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.
    log4j.rootLogger=DEBUG, stdout, log
    
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c:%L)%n
    
    log4j.logger.kafka=DEBUG
    log4j.logger.org.apache.kafka=DEBUG
    
    ### log file ###
    log4j.appender.log = org.apache.log4j.DailyRollingFileAppender
    log4j.appender.log.File = /Users/lizhitao/code/kafka-0.11.0.2-src/examples/logs/kafka.log
    log4j.appender.log.Append = true
    log4j.appender.log.Threshold = DEBUG
    log4j.appender.log.DatePattern='.'yyyy-MM-dd
    log4j.appender.log.layout = org.apache.log4j.PatternLayout
    log4j.appender.log.layout.ConversionPattern = [kafka][%p] [%-d{yyyy-MM-dd HH:mm:ss}] %C.%M(%L) | %m%n
    
    
    # zkclient can be verbose, during debugging it is common to adjust is separately
    log4j.logger.org.I0Itec.zkclient.ZkClient=WARN
    log4j.logger.org.apache.zookeeper=WARN
     

    No appenders could be found for logger,意思是log4.proproties找不到,如果默认位置找不到,我们可以自行动态配置

    generateData()方法加入如下log4j配置代码:

    PropertyConfigurator.configure("/Users/lizhitao/code/xxx-proj/kafka-0.11.0.2-src/examples/src/main/resources/log4j.properties");

    再次启动SimpleConsumerDemo,搞定,日志有输出

  • 相关阅读:
    重新梳理HTML基础知识
    Bootstrap响应式栅格系统的设计原理
    php 循环爬虫 or 持久执行任务 总断掉服务 解决,flush(),ob_flush()的组合使用
    Linux中工作目录切换命令
    Linux中系统状态检测命令
    Linux系统中rm删除命令
    Linux中touch命令使用(创建文件)
    Linux中 mkdir 创建文件夹命令
    Linux 中 cp 命令(文件复制)
    Linux中 mv(文件移动)
  • 原文地址:https://www.cnblogs.com/lizherui/p/8973618.html
Copyright © 2020-2023  润新知