日志系列之Log4j2 Garbage-free模式
2017-12-14 20:33
946 查看
Garbage-free核心思想:避免或减少对象的创建;
避免临时对象的创建;
From version 2.6, Log4j runs in “garbage free” mode by default where objects and buffers are reused and no temporary objects are allocated as much as possible. There is also a “low garbage” mode which is not completely garbage free but does not use ThreadLocal fields. This is the default mode when Log4j detects it is running in a web application.
log4j2.enableDirectEncoders - if “true” (the default) log events are converted to text and this text is converted to bytes without creating temporary objects.
实现方式
对象复用(threadlocal、jvm级别复用);避免临时对象的创建;
From version 2.6, Log4j runs in “garbage free” mode by default where objects and buffers are reused and no temporary objects are allocated as much as possible. There is also a “low garbage” mode which is not completely garbage free but does not use ThreadLocal fields. This is the default mode when Log4j detects it is running in a web application.
检测web应用
方式:检测javax.servlet.Servlet是否在classpath上;系统参数配置
log4j2.enableThreadlocals - if “true” (the default for non-web applications) objects are stored in ThreadLocal fields and reused, otherwise new objects are created for each log event.log4j2.enableDirectEncoders - if “true” (the default) log events are converted to text and this text is converted to bytes without creating temporary objects.
相关文章推荐
- SQL Server系列之 在发布复制模式下移动日志文件
- 轨迹系列——记某真实项目中轨迹展示查询效率优化方案二(日志模式)
- 日志系列之WEB应用中使用Log4j2
- 恢复系列3--归档模式下丢失非当前联机日志
- Spring Boot系列教程六:日志输出配置log4j2
- Spring Boot系列教程六:日志输出配置log4j2
- Spring Boot系列教程六:日志输出配置log4j2
- Log4j 2翻译 Garbage-free Steady State Logging(稳定的以不会生成垃圾的状态来记录日志)
- Apche日志系列(1):访问日志
- Delphi开发日志系列文章的示例源码
- 【推荐】【老外写的iOS设计模式系列】第1部分
- 深入理解数据库原理系列(1)---日志系统原理
- SpringBoot文档翻译系列——26.日志logging
- Android设计模式系列(4)--SDK源码之模板方法模式
- WP8.1学习系列(第十七章)——交互UX之输入和反馈模式
- 设计模式系列之 模式概述
- java设计模式系列之装饰者模式
- Java/Android 设计模式系列(2)--观察者模式
- 23种设计模式系列之策略模式。
- 行为的封装——模式系列谈之Command模式