zhisheng17/flink-learning · error · ConfigException
The bootstrap servers property must be specified
Error message
The bootstrap servers property must be specified
What it means
The Log4j 1.x KafkaLog4jAppender validates its options in activateOptions(). It throws ConfigException when bootstrapServers was not set (neither via the BootstrapServers option nor the bootstrap.servers property in log4j.properties), because the producer cannot connect without it.
Source
Thrown at flink-learning-extends/FlinkLogKafkaAppender/Log4jKafkaAppender/src/main/java/com/zhisheng/log/appender/KafkaLog4jAppender.java:92
if (log.contains("jobmanager")) {
containerType = "jobmanager";
} else if (log.contains("taskmanager")) {
containerType = "taskmanager";
} else {
containerType = "others";
}
} else {
log.error("log.file Property ({}) doesn't contains yarn application id or container id", logFile);
}
taskId = envProperties.getProperty("taskId", null);
taskName = envProperties.getProperty("taskName", null);
Properties props = new Properties();
if (this.bootstrapServers != null) {
props.setProperty("bootstrap.servers", this.bootstrapServers);
} else {
throw new ConfigException("The bootstrap servers property must be specified");
}
if (this.topic == null) {
throw new ConfigException("Topic must be specified by the Kafka log4j appender");
}
if (this.source == null) {
throw new ConfigException("Source must be specified by the Kafka log4j appender");
}
String clientIdPrefix = taskId != null ? taskId : appId;
if (clientIdPrefix != null) {
props.setProperty("client.id", clientIdPrefix + "_log");
}
if (this.acks != null) {
props.setProperty("acks", this.acks);
} else {
props.setProperty("acks", "0");View on GitHub (pinned to d731cee761)
Solutions
- Add log4j.appender.kafka.BootstrapServers=broker1:9092,broker2:9092 to log4j.properties.
- Or provide bootstrap.servers as one of the appender's properties.
- Confirm the log4j.properties in use at runtime contains the key (no shadowing config).
- Validate broker connectivity with kafka-console-producer using the same bootstrap list.
Example fix
// before (log4j.properties) log4j.appender.kafka=com.zhisheng.log.appender.KafkaLog4jAppender log4j.appender.kafka.Topic=app-logs // after log4j.appender.kafka=com.zhisheng.log.appender.KafkaLog4jAppender log4j.appender.kafka.BootstrapServers=broker1:9092,broker2:9092 log4j.appender.kafka.Topic=app-logs
Defensive patterns
Strategy: validation
Validate before calling
java.util.Properties p = new java.util.Properties();
p.load(new FileInputStream("log4j.properties"));
if (p.getProperty("log4j.appender.kafka.BootstrapServers") == null)
throw new IllegalStateException("BootstrapServers missing for KafkaLog4jAppender"); Try / catch
try {
PropertyConfigurator.configure("log4j.properties");
} catch (Throwable t) {
System.err.println("Log4j Kafka appender config error: " + t.getMessage());
} Prevention
- Always set BootstrapServers in log4j.properties appender blocks
- Validate log4j.properties keys in CI before deployment
- Use environment-agnostic placeholders substituted at deploy time
- Check key spelling: BootstrapServers, not bootstrap.servers as a bare option
When it happens
Trigger: log4j.properties defining com.zhisheng.log.appender.KafkaLog4jAppender without BootstrapServers, then logger initialization calls activateOptions().
Common situations: Misspelled key ('boostrap.servers'); property provided only in a different config file; migrating configs between environments where the property was dropped.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- Topic must be specified by the Kafka log4j appender
- Source must be specified by the Kafka log4j appender
- The bootstrap servers property must be specified
- Topic must be specified by the Kafka log4j appender
- invalid elasticsearch hosts format
AI-assisted analysis of zhisheng17/flink-learning@d731cee761 (2026-09-06).
Data as JSON: /api/errors/a3d498f2002d5ea6.
Report an issue: GitHub.