• 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,搞定,日志有输出

  • 相关阅读:
    POI实现Excel导入数据库数据
    POI对Excel进行读取操作,工具类,便于操作数据
    HAProxy-1.8.20 根据后缀名转发到后端服务器
    Haproxy-1.8.20 编译安装:
    Soat控制HaProxy 动态增减服务器
    Haproxy-1.8.20 根据路径(URI)转发到后端不同集群
    Ansible User 模块添加单用户并ssh-key复制
    Ansible-playbook 安装redis
    二进制安装mysql-5.7.28
    编译安装 nginx -1.14.2
  • 原文地址:https://www.cnblogs.com/lizherui/p/8973618.html
Copyright © 2020-2023  润新知