logback-kafka-appender
logback 日志写入kafka队列
logback-kafka-appender
Logback incompatibility Warning
Due to a bug in logback-core (LOGBACK-1158), 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]
<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>
<version>1.1.2</version>
<scope>runtime</scope>
</dependency>
// [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]
<configuration> <appender name="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 -->
<appender name="kafkaAppender" class="com.github.danielwegener.logback.kafka.KafkaAppender">
<!-- This is the default encoder that encodes every log message to an utf8-encoded string -->
<encoder class="com.github.danielwegener.logback.kafka.encoding.LayoutKafkaMessageEncoder">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</layout>
</encoder>
<topic>logs</topic>
<keyingStrategy class="com.github.danielwegener.logback.kafka.keying.RoundRobinKeyingStrategy" />
<deliveryStrategy class="com.github.danielwegener.logback.kafka.delivery.AsynchronousDeliveryStrategy" /> <!-- each <producerConfig> translates to regular kafka-client config (format: key=value) -->
<!-- producer configs are 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的更多相关文章
- java日志框架系列(5):logback框架appender详解
1.appender 1.什么是appender Appender 是负责写记录事件的组件. Appender 必须实现接口“ch.qos.logback.core.Appender”.该接口的重要方 ...
- logback中appender继承
实例: <?xml version="1.0" encoding="UTF-8"?> <configuration debug="t ...
- logback KafkaAppender 写入Kafka队列,集中日志输出.
为了减少应用服务器对磁盘的读写,以及可以集中日志在一台机器上,方便使用ELK收集日志信息,所以考虑做一个jar包,让应用集中输出日志 网上搜了一圈,只发现有人写了个程序在github 地址:https ...
- logback输出json格式日志(包括mdc)发送到kafka
1,pom.xml <!-- kafka --> <dependency> <groupId>com.github.danielwegener</groupI ...
- logback kafkaAppender输出日志到kafka
官网地址https://github.com/danielwegener/logback-kafka-appender 本文以spring boot项目为基础,更多的信息,请参考官网 https:// ...
- Logback中文文档(四):Appender
什么是 Appender Appender是负责写记录事件的组件.Appender 必须实现接口"ch.qos.logback.core.Appender".该接口的重要方法总结如 ...
- SpringBoot+kafka+ELK分布式日志收集
一.背景 随着业务复杂度的提升以及微服务的兴起,传统单一项目会被按照业务规则进行垂直拆分,另外为了防止单点故障我们也会将重要的服务模块进行集群部署,通过负载均衡进行服务的调用.那么随着节点的增多,各个 ...
- 微服务日志之Spring Boot Kafka实现日志收集
前言 承接上文( 微服务日志之.NET Core使用NLog通过Kafka实现日志收集 https://www.cnblogs.com/maxzhang1985/p/9522017.html ).NE ...
- SpringBoot | 第二十五章:日志管理之自定义Appender
前言 前面两章节我们介绍了一些日志框架的常见配置及使用实践.一般上,在开发过程中,像log4j2.logback日志框架都提供了很多Appender,基本上可以满足大部分的业务需求了.但在一些特殊需求 ...
- Spring Cloud Sleuth通过Kafka将链路追踪日志输出到ELK
1.工程简介 elk-eureka-server作为其他三个项目的服务注册中心 elk-kafka-client调用elk-kafka-server,elk-kafka-server再调用elk-ka ...
随机推荐
- XML 高速入门总结
XML已经学习完了一段时间了.一直感觉知识比較琐碎,没有去好好总结.事实上越琐碎的知识也越须要我们去好好 理一下.将知识串起来.争取变得不再琐碎.以下是我学完xml画的一张图. 以下对XML进行一下简 ...
- Odoo(OpenERP)配置文件openerp-server.conf详解
原文地址:http://blog.csdn.net/wangnan537/article/details/42283465 [options] ; addons模块的查找路径 addons_path ...
- #ifdef #else #endif 的用法
预处理就是在进行编译的第一遍词法扫描和语法分析之前所作的工作.说白了,就是对源文件进行编译前,先对预处理部分进行处理,然后对处理后的代码进行编译.这样做的好处是,经过处理后的代码,将会变的很精短. 关 ...
- C#编程(七十二)----------DynamicObject和ExpandoObject
DynamicObject和ExpandoObject 1.ExpandoObject表示一个对象,该对象包含可在运行时动态添加和移除的成员.这个类和动态类型有关,这个类能做些什么? 案例: //Ex ...
- C#编程(十七)----------Object类
Object类 它是.NET Framework 中所有类的最终基类:它是类型层次结构的根.也就是说所有的类都拥有object类的方法,并能重写,调用. object的构造函数:public Obje ...
- C# TextWriter类
来自:https://www.yiibai.com/csharp/c-sharp-textwriter.html C# TextWriter类是一个抽象类.它用于将文本或连续的字符串写入文件.它在Sy ...
- Linux tar包相关命令
tar [-j|-z][cv][-f 新建的文件名] filename... <==打包与压缩 tar [-j|-z][tv][-f 新建的文件名] <==查看文件名 tar [-j| ...
- Mysql添加和删除唯一索引、主键
1.PRIMARY KEY(主键索引) 添加 ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` );删除 ALTER TABLE `table_n ...
- mysql 比较函数和操作符
MYSQL之中的比较函数和操作符: 1.[NOT] BETWEEN ... AND ... Check whether a value is within a range of values 说明: ...
- Android之greenDao,一个orm的使用
转自:http://blog.csdn.net/krislight/article/details/9391455 greenDaoMaster的学习研究 分类: 心得笔记 2013-07-20 16 ...