Logback-kafka-appender

Source: Internet
Author: User

logback Log write Kafka queueLogback-kafka-appender

Logback incompatibility Warning

Due to a bug in Logback-core (LOGBACK-1158), Logback-kafka-appender does isn't work with Logback 1.1.7. This bug would be a 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 and as logback-kafka-appender logback-classic Library dependencies to your project.

[Maven pom.xml]<dependency> <groupid>com.github.danielwegener</groupid> <artifactid>logback-kafka-appender</ artifactid> <version>0.1.0</version> <scope>runtime</scope></dependency><dependency> <groupid>ch.qos.logback</ groupid> <artifactid>logback-classic</artifactId> << Span class= "pl-ent" >version>1.1.2</version> <scope> Runtime</scope></DEPENDENCY>     
 //[build.sbt]librarydependencies + =  "Com.github.danielwegener" Span class= "Pl-k" >%  "Logback-kafka-appender" %  "0.1.0" Librarydependencies +=  "Ch.qos.logback "% " Logback-classic " %  "1.1.7"        

This is a example, logback.xml uses a common to PatternLayout encode a log message as a string.

[src/main/resources/logback.xml]<Configuration> <AppenderName="STDOUT"class="Ch.qos.logback.core.ConsoleAppender"> <Encoder> <Pattern>%d{hh:mm:ss. SSS} [%thread]%-5level%logger{36}-%msg%n</Pattern> </Encoder> </Appender><!--this is the Kafkaappender-<AppenderName="Kafkaappender"class="Com.github.danielwegener.logback.kafka.KafkaAppender"><!--This is the default encoder, encodes every log message to an utf8-encoded string-<Encoderclass="Com.github.danielwegener.logback.kafka.encoding.LayoutKafkaMessageEncoder"> <Layoutclass="Ch.qos.logback.classic.PatternLayout"> <Pattern>%d{hh:mm:ss. SSS} [%thread]%-5level%logger{36}-%msg%n</Pattern> </Layout> </Encoder> <topic>logs</Topic> <Keyingstrategyclass="Com.github.danielwegener.logback.kafka.keying.RoundRobinKeyingStrategy"/> <Deliverystrategyclass="Com.github.danielwegener.logback.kafka.delivery.AsynchronousDeliveryStrategy"/><!--each <producerConfig> translates to regular kafka-client config (format:key=value)-<!--producer Configs is documented here:https://kafka.apache.org/documentation.html#newproducerconfigs-<!--Bootstrap.servers is the only mandatory producerconfig--> <producerconfig>bootstrap.servers=localhost:9092</producerconfig> <!--This is the fallback appender if Kafka is not available. --> <appender-ref ref= "Stdout"/> </appender> < root level= "info  "> <appender-ref ref= "Kafkaappender"/> </root></ CONFIGURATION>            

Logback-kafka-appender

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.