zoukankan      html  css  js  c++  java
  • 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,搞定,日志有输出

  • 相关阅读:
    Kendo UI for ASP.NET MVC 的一些使用经验
    AI智能技术监控学生上课行为,智慧管理加强校园教学质量
    如何通过ffmpeg 实现实时推流和拉流保存的功能
    如何测试流媒体服务器的并发能力?
    TSINGSEE青犀视频H265播放器FLV.js播放一段时间后报内存不足怎么处理?
    互动电视的未来应该是什么样的?
    牛客练习赛89 题解
    【洛谷P3934】炸脖龙 I
    【CF1463F】Max Correct Set
    【CF1496F】Power Sockets
  • 原文地址:https://www.cnblogs.com/lizherui/p/8973618.html
Copyright © 2011-2022 走看看