You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

启动Kafka时遇No appenders could be found日志报错,已配置log4j仍未解决

Fixing "No appenders could be found for logger (kafka.server.KafkaConfig)" in Kafka

Hey there, let's work through this Kafka log4j issue together—this error usually boils down to Kafka not being able to locate or load the correct log4j configuration file. Let's go through the fixes step by step:

1. Fix the log4j.properties file location & name first

Your renaming to core-src-scala-log4j.properties is likely the problem here. Kafka expects the log4j config file to be named log4j.properties and placed directly in the config folder of your Kafka installation directory.

For example, if Kafka is installed at /usr/local/kafka, the correct path should be /usr/local/kafka/config/log4j.properties. Move your file here and restore its original name—forget that custom renaming, it's not needed.

2. Verify the Kafka startup script points to the right config

Open the kafka-server-start.sh script (located in the bin folder of your Kafka install) and check if it explicitly sets the log4j configuration path. Look for a line like:

export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$KAFKA_HOME/config/log4j.properties"

If this line is missing or the path is incorrect, add/update it with your actual Kafka installation path. This ensures the startup process knows exactly where to find the log4j config.

3. Make sure your log4j.properties has valid appender configs

An empty or malformed log4j file will also trigger this error. At minimum, your file should have a basic console appender set up. Here's a working minimal example you can use:

log4j.rootLogger=INFO, console

# Console appender configuration
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

Replace your current file content with this if you're unsure about your existing config.

4. Check your KAFKA_HOME environment variable

Ensure the KAFKA_HOME variable is set correctly to your Kafka installation directory. Run this in your terminal to check:

echo $KAFKA_HOME

If it returns nothing, set it temporarily with:

export KAFKA_HOME=/path/to/your/kafka
export PATH=$PATH:$KAFKA_HOME/bin

For permanent setup, add these lines to your shell profile (like ~/.bashrc or ~/.zshrc).

5. Clean up residual logs & restart

If you've been testing multiple configs, there might be cached log files causing issues. Stop any running Kafka processes, delete the contents of the logs folder in your Kafka directory, then try starting Kafka again with:

kafka-server-start.sh $KAFKA_HOME/config/server.properties

Most of the time, fixing the file location/name and verifying the startup script's log4j path resolves this error immediately. Give these steps a shot and let me know if you run into any snags!

内容的提问来源于stack exchange,提问作者林孟飞

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:11:45