logback 日志写入kafka队列
Logback incompatibility Warning
Due to a bug in logback-core (), logback-kafka-appender does not work with logback 1.1.7. This bug will be fixed in the upcoming logback 1.1.8. Until 1.1.8 is released, we recommend to use logback 1.1.6.
Full configuration example
Add logback-kafka-appender
and logback-classic
as library dependencies to your project.
[maven pom.xml] com.github.danielwegener logback-kafka-appender 0.1.0 runtime ch.qos.logback logback-classic 1.1.2 runtime
// [build.sbt]libraryDependencies += "com.github.danielwegener" % "logback-kafka-appender" % "0.1.0" libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.7"
This is an example logback.xml
that uses a common PatternLayout
to encode a log message as a string.
[src/main/resources/logback.xml] %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n logs bootstrap.servers=localhost:9092