“Log4j 2 异步日志”的版本间的差异
跳到导航
跳到搜索
Jihongchang(讨论 | 贡献) (→同步日志) |
Jihongchang(讨论 | 贡献) |
||
第11行: | 第11行: | ||
[[文件:Log4j 2 异步日志流程.png|无|缩略图|1002x1002像素]] | [[文件:Log4j 2 异步日志流程.png|无|缩略图|1002x1002像素]] | ||
Log4j 2 提供了两种实现日志的方式,一个是通过 AsyncAppender,一个是通过 AsyncLogger,分别对应前面的 Appender 组件和 Logger 组件 | Log4j 2 提供了两种实现日志的方式,一个是通过 AsyncAppender,一个是通过 AsyncLogger,分别对应前面的 Appender 组件和 Logger 组件 | ||
+ | |||
+ | 实际一般使用 AsyncLogger | ||
+ | |||
+ | 注意:配置异步日志需要添加依赖<syntaxhighlight lang="xml"> | ||
+ | <!-- 异步日志依赖 --> | ||
+ | <dependency> | ||
+ | <groupId>com.lmax</groupId> | ||
+ | <artifactId>disruptor</artifactId> | ||
+ | <version>3.3.4</version> | ||
+ | </dependency> | ||
+ | </syntaxhighlight> |
2023年2月28日 (二) 04:39的版本
https://www.bilibili.com/video/BV1iJ411H74S?p=34
Log4j 2 最大的特点就是异步日志,其性能的提升主要也是从异步日志中受益
Log4j 2 同步日志流程
Log4j 2 异步日志流程
Log4j 2 提供了两种实现日志的方式,一个是通过 AsyncAppender,一个是通过 AsyncLogger,分别对应前面的 Appender 组件和 Logger 组件
实际一般使用 AsyncLogger
注意:配置异步日志需要添加依赖
<!-- 异步日志依赖 -->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.3.4</version>
</dependency>