sil
sil

Reputation: 450

Where are the application logs saved on a kafka broker?

I imagine that this depends on my configuration, but how do I find the application logs in a kafka broker. I want to view WARN and ERROR messages that may have resulted from failed attempts to connect to it.

If there is no default location, then which configuration defines the location?

Please note, I do not mean the actual kafka log, where the messages are stored. This naming made it hard to google for what I looking for!

Upvotes: 3

Views: 10915

Answers (1)

pgras
pgras

Reputation: 12780

If you want to see the broker logs, as Kafka uses Log4j you can look at the log4j.properties used by kafka default one.

I will not describe the whole file but following lines show that the logs are printed on stdout and that the logs are appended to the file ${kafka.logs.dir}/server.log. The value of kafka.logs.dir is loaded from the server.properties at startup (default one)

log4j.rootLogger=INFO, stdout, kafkaAppender

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

log4j.appender.kafkaAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.kafkaAppender.DatePattern='.'yyyy-MM-dd-HH
log4j.appender.kafkaAppender.File=${kafka.logs.dir}/server.log
log4j.appender.kafkaAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.kafkaAppender.layout.ConversionPattern=[%d] %p %m (%c)%n

But depending on why you failed to connect to the broker, you may never see a log on the broker side, and should rather look at the logs on the client side (where kafka is also using log4j).

Upvotes: 4

Related Questions