zhisheng17/flink-learning · error · ConfigException
The bootstrap servers property must be specified
Error message
The bootstrap servers property must be specified
What it means
KafkaLog4j2Appender (Log4j2) requires the Kafka 'bootstrap.servers' setting to connect to the cluster. During appender initialization, if neither the bootstrapServers attribute nor any property named bootstrap.servers was provided, it throws Kafka's ConfigException and the appender fails to start.
Source
Thrown at flink-learning-extends/FlinkLogKafkaAppender/Log4j2KafkaAppender/src/main/java/com/zhisheng/log/appender/KafkaLog4j2Appender.java:107
containerType = "others";
}
} else {
log.error("log.file Property ({}) doesn't contains yarn application id or container id", logFile);
}
}
taskName = envProperties.getProperty("taskName", null);
taskId = envProperties.getProperty("taskId", null);
Properties props = new Properties();
for (Property property : properties) {
props.put(property.getName(), property.getValue());
}
if (bootstrapServers != null) {
props.setProperty("bootstrap.servers", 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");
}
String clientIdPrefix = taskId != null ? taskId : appId;
if (clientIdPrefix != null) {
props.setProperty("client.id", clientIdPrefix + "_log");
}
if (props.getProperty("acks") == null) {
props.setProperty("acks", "0");
}
if (props.getProperty("retries") == null) {
props.setProperty("retries", "0");
}View on GitHub (pinned to d731cee761)
Solutions
- Add bootstrapServers="host1:9092,host2:9092" to the <KafkaLog4j2Appender> element in log4j2.xml.
- Or add <Property name="bootstrap.servers">host:9092</Property> inside the appender configuration.
- Verify the Kafka brokers are reachable at the configured address.
- Check that the deployed log4j2.xml is the one actually being loaded (config file path/sys property).
Example fix
// before (log4j2.xml) <KafkaLog4j2Appender topic="app-logs"/> // after <KafkaLog4j2Appender topic="app-logs" bootstrapServers="broker1:9092,broker2:9092"/>
Defensive patterns
Strategy: validation
Validate before calling
String bootstrap = System.getProperty("kafka.bootstrap", "broker1:9092");
if (bootstrap == null || bootstrap.isEmpty())
throw new IllegalStateException("bootstrap.servers must be set before initializing KafkaLog4j2Appender"); Try / catch
try {
LOGGER.info("startup");
} catch (Throwable t) {
System.err.println("Kafka appender init failed: " + t.getMessage());
// fall back to console appender
} Prevention
- Always set bootstrapServers (or a bootstrap.servers Property) in log4j2.xml
- Keep one canonical log4j2.xml template with required attributes filled via variables
- Smoke-test logging config in CI with a real broker
- Grep deployment configs for 'bootstrapServers' before release
When it happens
Trigger: Configuring the appender in log4j2.xml without the bootstrapServers attribute and without a <Property name="bootstrap.servers"> entry, then logging triggers appender start.
Common situations: Missing attribute in log4j2.xml; property name misspelled (e.g. 'boostrap.servers'); relying on an environment-specific property that isn't defined in the deployed config.
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
- The bootstrap servers property must be specified
- Topic must be specified by the Kafka log4j appender
- Source 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/61248c878f430b6e.
Report an issue: GitHub.