【问题标题】:log4j fails in Apache Kafkalog4j 在 Apache Kafka 中失败
【发布时间】:2022-01-10 12:37:57
【问题描述】:

我是 Apache Kafka 的新手,我正在使用 this 设置一个 Kafka 3.0.0 ZooKeeper-less kafka 集群。当我尝试生成存储随机 UUID 时,我得到:

//opt/kafka_2.13-3.0.0> ./bin/kafka-storage.sh random-uuid

log4j:ERROR Could not read configuration file from URL [file://opt/kafka_2.13-3.0.0/bin/../config/tools-log4j.properties].
java.net.UnknownHostException: opt
    at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:567)
    at java.base/java.net.Socket.connect(Socket.java:633)
    at java.base/sun.net.ftp.impl.FtpClient.doConnect(FtpClient.java:1045)
    at java.base/sun.net.ftp.impl.FtpClient.tryConnect(FtpClient.java:1010)
    at java.base/sun.net.ftp.impl.FtpClient.connect(FtpClient.java:1102)
    at java.base/sun.net.ftp.impl.FtpClient.connect(FtpClient.java:1088)
    at java.base/sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:320)
    at java.base/sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:426)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:557)
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
    at org.slf4j.impl.Log4jLoggerFactory.<init>(Log4jLoggerFactory.java:66)
    at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:72)
    at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:45)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:417)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:362)
    at com.typesafe.scalalogging.Logger$.apply(Logger.scala:31)
    at kafka.utils.Log4jControllerRegistration$.<clinit>(Logging.scala:25)
    at kafka.tools.StorageTool$.<clinit>(StorageTool.scala:32)
    at kafka.tools.StorageTool.main(StorageTool.scala)
log4j:ERROR Ignoring configuration file [file://opt/kafka_2.13-3.0.0/bin/../config/tools-log4j.properties].
log4j:WARN No appenders could be found for logger (kafka.utils.Log4jControllerRegistration$).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

znl51P7oQX2GDsfi2FRE7g

Si 我得到了 UUID,但似乎没有日志记录。这是卡夫卡的错误吗?还是我在设置中遗漏了什么?

文件 tools-log4j.properties 位于正确的位置并具有正确的权限。文件内容:

> cat /opt/kafka_2.13-3.0.0/config/tools-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.

log4j.rootLogger=WARN, stderr

log4j.appender.stderr=org.apache.log4j.ConsoleAppender
log4j.appender.stderr.layout=org.apache.log4j.PatternLayout
log4j.appender.stderr.layout.ConversionPattern=[%d] %p %m (%c)%n
log4j.appender.stderr.Target=System.err

谢谢。

【问题讨论】:

    标签: java logging apache-kafka log4j


    【解决方案1】:

    这是双反斜杠...如果我这样做:

    /opt/kafka_2.13-3.0.0> ./bin/kafka-storage.sh random-uuid
    

    而不是

    //opt/kafka_2.13-3.0.0> ./bin/kafka-storage.sh random-uuid
    

    它有效,另见this。去图...

    【讨论】:

      猜你喜欢
      • 2017-06-13
      • 1970-01-01
      • 1970-01-01
      • 2018-04-26
      • 2022-12-05
      • 2018-09-04
      • 2018-03-30
      • 2021-04-04
      • 1970-01-01
      相关资源
      最近更新 更多