The log4j system fails in Apache Kafka

I am new to Apache Kafka and I am using this for setting up a Kafka 3.0.0 ZooKeeper-less kafka cluster. When I try to generate a storage random UUID, I get:

//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 I get the UUID, but there seems to be no logging. Is this a Kafka bug? Or have I missed something in the setup?

The file tools-log4j.properties is in the right place and with the right permissions. File content:

> 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

Thanks.

1 Like

Hi @ElToro

I think it’s related to the “double-slash” in your path:

I did some tests in my local dev env and received the same errors if
the path starts with to leading slashes

echo $PWD
//app/kafka_2.13-3.0.0
kafka@kafka01://app/kafka_2.13-3.0.0$ ./bin/kafka-storage.sh random-uuid
log4j:ERROR Could not read configuration file from URL [file://app/kafka_2.13-3.0.0/bin/../config/tools-log4j.properties].
java.net.UnknownHostException: app
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
[...]

echo $PWD
/app/kafka_2.13-3.0.0
kafka@kafka01:/app/kafka_2.13-3.0.0$ ./bin/kafka-storage.sh random-uuid
fiFgAngERZK9FDh-ygLf_A

HTH,
Michael

2 Likes

That worked! Thanks.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.