- 浏览: 804450 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (360)
- Java (101)
- JPA/Hibernate (10)
- Spring (14)
- Flex/BlazeDS (37)
- Database (30)
- Lucene/Solr/Nutch (0)
- Maven/Ant (25)
- CXF/WebService (3)
- RPC/RMI/SOAP/WSDL (1)
- REST (6)
- TDD/BDD/JUnit (1)
- Servlet/JSP (2)
- AI/MachineLearning (3)
- Resource (1)
- 字符编码 (2)
- OOA/OOPS/UML (5)
- DesignPattern (8)
- 算法与数据结构 (11)
- Web&App Server (13)
- 并发&异步&无阻塞 (7)
- Entertainment (4)
- JavaScript/ExtJS (45)
- CodeStyle&Quality (1)
- svn/git/perforce (8)
- JSON (2)
- JavaScriptTesting (4)
- Others (6)
- RegularExpression (2)
- Linux/Windows (12)
- Protocal (2)
- Celebrities (1)
- Interview (1)
- 计算机语言 (1)
- English (2)
- Eclipse (5)
- TimeZone/时区 (1)
- Finance (1)
- 信息安全 (1)
- JMS/MQ (2)
- XSD/XML/DTD (3)
- Android (4)
- 投资 (3)
- Distribution (3)
- Excel (1)
最新评论
-
qdujunjie:
如果把m换成具体的数字,比如4或者5,会让读者更明白
m阶B树中“阶”的含义 -
java-admin:
不错,加油,多写点文章
关于Extjs的mixins和plugin -
xiehuaidong880827:
你好,我用sencha cmd打包完本地工程后,把app.js ...
ExtJS使用Sencha Cmd合并javascript文件为一个文件 -
KIWIFLY:
lwpan 写道inverse = "true&qu ...
Hibernate中什么时候使用inverse=true -
luedipiaofeng:
good
消除IE stop running this script弹出框
logback prudent, SiftingAppender, layout, encoder的使用
- 博客分类:
- Java
1. 将prudent设置为true 是为了支持多个JVM往同一个日志文件写日志.
参考http://logback.qos.ch/manual/appenders.html#FileAppender里面的prudent描述
prudent
In prudent mode, FileAppender will safely write to the specified file, even in the presence of other FileAppender instances running in different JVMs, potentially running on different hosts. The default value for prudent mode is false.
Prudent mode can be used in conjunction with RollingFileAppender although some restrictions apply.
Prudent mode implies that append property is automatically set to true.
Prudent more relies on exclusive file locks. Experiments show that file locks approximately triple (x3) the cost of writing a logging event. On an "average" PC writing to a file located on a local hard disk, when prudent mode is off, it takes about 10 microseconds to write a single logging event. When prudent mode is on, it takes approximately 30 microseconds to output a single logging event. This translates to logging throughput of 100'000 events per second when prudent mode is off and approximately 33'000 events per second in prudent mode.
Prudent mode effectively serializes I/O operations between all JVMs writing to the same file. Thus, as the number of JVMs competing to access a file increases so will the delay incurred by each I/O operation. As long as the total number of I/O operations is in the order of 20 log requests per second, the impact on performance should be negligible. Applications generating 100 or more I/O operations per second can see an impact on performance and should avoid using prudent mode.
NETWORKED FILE LOCKS When the log file is located on a networked file system, the cost of prudent mode is even greater. Just as importantly, file locks over a networked file system can be sometimes strongly biased such that the process currently owning the lock immediately re-obtains the lock upon its release. Thus, while one process hogs the lock for the log file, other processes starve waiting for the lock to the point of appearing deadlocked.
The impact of prudent mode is highly dependent on network speed as well as the OS implementation details. We provide an very small application called FileLockSimulator which can help you simulate the behavior of prudent mode in your environment.
2. SiftingAppender: logging different threads to different log files
http://www.nurkiewicz.com/2013/04/siftingappender-logging-different.html
Encoder and Layout-Pattern.
原文:http://logback.qos.ch/codes.html#layoutInsteadOfEncoder
This appender no longer admits a layout as a sub-component, set an encoder instead.
As of logback version 0.9.19, the WriterAppender class has been renamed as OutputStreamAppender, with FileAppender now sub-classing the latter. OutputStreamAppender and sub-classes now take an Encoder as a sub-component instead of a Layout.
In practical terms, this means that configuration files need to be changed
from (DEPRECATED)
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%msg%n</pattern>
</layout>
</appender>
or the shorter equivalent (DEPRECATED)
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<!-- layout are assigned the type ch.qos.logback.classic.PatternLayout by default -->
<layout>
<pattern>%msg%n</pattern>
</layout>
</appender>
to (GOOD)
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%msg%n</pattern>
</encoder>
</appender>
or the shorter equivalent (GOOD)
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender>
For layout type other than PatternLayout, for example HTMLLayout, your configuration files need to be changed
from (DEPRECATED)
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<layout class="ch.qos.logback.classic.html.HTMLLayout">
<pattern>%msg%n</pattern>
</layout>
</appender>
to (GOOD)
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.html.HTMLLayout">
<pattern>%msg%n</pattern>
</layout>
</encoder>
</appender>
We hope to make up for this inconvenience with cool new features which are only possible using encoders. During a transition period, layouts passed as parameter will be automatically wrapped by an encoder so that configuration files in the old format (using a layout instead of encoder) will continue to work unmodified.
参考http://logback.qos.ch/manual/appenders.html#FileAppender里面的prudent描述
prudent
In prudent mode, FileAppender will safely write to the specified file, even in the presence of other FileAppender instances running in different JVMs, potentially running on different hosts. The default value for prudent mode is false.
Prudent mode can be used in conjunction with RollingFileAppender although some restrictions apply.
Prudent mode implies that append property is automatically set to true.
Prudent more relies on exclusive file locks. Experiments show that file locks approximately triple (x3) the cost of writing a logging event. On an "average" PC writing to a file located on a local hard disk, when prudent mode is off, it takes about 10 microseconds to write a single logging event. When prudent mode is on, it takes approximately 30 microseconds to output a single logging event. This translates to logging throughput of 100'000 events per second when prudent mode is off and approximately 33'000 events per second in prudent mode.
Prudent mode effectively serializes I/O operations between all JVMs writing to the same file. Thus, as the number of JVMs competing to access a file increases so will the delay incurred by each I/O operation. As long as the total number of I/O operations is in the order of 20 log requests per second, the impact on performance should be negligible. Applications generating 100 or more I/O operations per second can see an impact on performance and should avoid using prudent mode.
NETWORKED FILE LOCKS When the log file is located on a networked file system, the cost of prudent mode is even greater. Just as importantly, file locks over a networked file system can be sometimes strongly biased such that the process currently owning the lock immediately re-obtains the lock upon its release. Thus, while one process hogs the lock for the log file, other processes starve waiting for the lock to the point of appearing deadlocked.
The impact of prudent mode is highly dependent on network speed as well as the OS implementation details. We provide an very small application called FileLockSimulator which can help you simulate the behavior of prudent mode in your environment.
2. SiftingAppender: logging different threads to different log files
http://www.nurkiewicz.com/2013/04/siftingappender-logging-different.html
Encoder and Layout-Pattern.
原文:http://logback.qos.ch/codes.html#layoutInsteadOfEncoder
This appender no longer admits a layout as a sub-component, set an encoder instead.
As of logback version 0.9.19, the WriterAppender class has been renamed as OutputStreamAppender, with FileAppender now sub-classing the latter. OutputStreamAppender and sub-classes now take an Encoder as a sub-component instead of a Layout.
In practical terms, this means that configuration files need to be changed
from (DEPRECATED)
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%msg%n</pattern>
</layout>
</appender>
or the shorter equivalent (DEPRECATED)
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<!-- layout are assigned the type ch.qos.logback.classic.PatternLayout by default -->
<layout>
<pattern>%msg%n</pattern>
</layout>
</appender>
to (GOOD)
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%msg%n</pattern>
</encoder>
</appender>
or the shorter equivalent (GOOD)
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%msg%n</pattern>
</encoder>
</appender>
For layout type other than PatternLayout, for example HTMLLayout, your configuration files need to be changed
from (DEPRECATED)
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<layout class="ch.qos.logback.classic.html.HTMLLayout">
<pattern>%msg%n</pattern>
</layout>
</appender>
to (GOOD)
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>testFile.log</file>
...
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.html.HTMLLayout">
<pattern>%msg%n</pattern>
</layout>
</encoder>
</appender>
We hope to make up for this inconvenience with cool new features which are only possible using encoders. During a transition period, layouts passed as parameter will be automatically wrapped by an encoder so that configuration files in the old format (using a layout instead of encoder) will continue to work unmodified.
发表评论
-
sapjco3 notes
2019-03-21 14:51 1163sapjco https://support.sap.com/ ... -
使用RestTemplate发送post JSON请求
2019-01-12 17:30 4741private final String BASE_URL = ... -
使用RestTemplate发送post JSON请求
2019-01-12 17:30 3506private final String BASE_URL = ... -
Spring线程池ThreadPoolTaskExecutor
2018-08-06 09:51 1887<!-- spring thread pool ex ... -
Spring注解事物@Transactional不工作
2018-08-02 18:50 2676“In proxy mode (which is the de ... -
创建前缀索引报长度超出错误
2018-07-25 15:44 1731表结构定义如下: CREATE TABLE `sku` ( ` ... -
Mysql Varchar字符长度
2018-07-25 15:23 1352`sku_name` VARCHAR(200) NOT NUL ... -
使用 Spring RestTemplate 发送 post 请求
2018-07-23 18:49 11727注意点: 1)使用MultiValueMap设置入参,不要使 ... -
Java动态代理Dynamic Proxy
2018-07-21 16:33 814JAVA学习篇--静态代理VS动态代理 https://blo ... -
分布式实时日志分析解决方案 ELK 部署架构
2018-07-20 09:52 1189原文链接:http://www.importn ... -
为什么HashMap容量一定要为2的幂呢?
2018-07-19 10:07 1728原文链接:https://blog.csdn.net/wang ... -
为什么计算HashCode时通常选择31这个数?
2018-07-19 10:05 1422摘自http://www.importnew.com/2208 ... -
jackson自定义序列化和反序列化
2018-07-10 18:47 2243原文链接:https://blog.csdn.net/liu ... -
Pay special attention when modifying online running system
2017-06-23 10:25 0Never remove any properties, me ... -
Map中的Null key, Null Value
2017-06-14 10:52 1946ConcurrentHashMap的key和value都不能为 ... -
Java语法糖
2017-06-05 20:03 530Java语法糖之foreach http://www.imp ... -
Java集合相关
2017-05-24 17:55 0Java集合框架:ArrayList http://www. ... -
Java数据类型的转换:隐式(自动)转换与强制转换
2017-05-14 10:46 0http://blog.csdn.net/u011240877 ... -
分布式开放消息系统(RocketMQ)的原理与实践
2017-05-07 19:55 731分布式开放消息系统(RocketMQ)的原理与实践 http ... -
面试知识点复习(Interview knowledge review)
2017-05-07 18:39 0JVM,多线程相关知识 http://darrenzhu.it ...
相关推荐
Logstash Logback编码器 提供编码器,布局和附加程序,以JSON和登录。 支持常规LoggingEvents (通过Logger )和AccessEvents (通过记录)。 最初是为了支持的JSON格式的输出而的,但现在已经演变为针对JSON和...
java运行依赖jar包
Logback 使用 `logback.xml` 文件进行配置。配置文件中,你可以定义日志级别、过滤器、appender 和 layout。例如: ```xml <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> ...
- `ch.qos.logback.classic.encoder` 包含了用于格式化日志消息的 Encoder 类,如 PatternLayoutEncoder。 - `ch.qos.logback.classic.filter` 提供了多种过滤器,如 LevelMatchFilter、DenyAllFilter 等,允许...
`logback-android`提供了多种内置Appender和Layout,例如ConsoleAppender、FileAppender、PatternLayout等。开发者可以根据需求自定义Appender和Layout,实现更复杂的功能。 ### 6. 性能优化 考虑到Android设备的...
java运行依赖jar包
Logback中文文档是一份关于Logback使用和配置的全面指南,它提供了深入的理论知识和实用的API应用,覆盖了Logback的几乎所有重要方面。 在这份文档中,首先介绍了Logback的基础概念。文档解释了什么是Logback,它的...
3. **layout(布局)配置**:定义日志输出的格式,如`<layout class="ch.qos.logback.classic.PatternLayout">`,并设置模式 `%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n`,将输出时间戳...
以下是使用logback+slf4j自定义Appender的详细步骤: 1. **创建Appender类**:首先,你需要创建一个继承自`ch.qos.logback.core.AppenderBase<ILoggingEvent>`的类。在这个类中,你需要覆盖`append()`方法,该方法...
标题"Logback的使用和logback.xml详解"暗示了我们要讨论的是一个日志管理框架——Logback,以及它的配置文件`logback.xml`。Logback是Java社区广泛使用的日志处理系统,由Ceki Gülcü创建,作为Log4j的后继者。它...
在使用Logback之前,首先需要在项目中引入必要的jar包。根据提供的压缩包文件名"logback所需jar包",我们可以推测这个压缩包包含了Logback运行所需的库文件。通常,这些文件包括`logback-classic.jar`, `logback-...
logstash-logback-encoder就是转码后向logstash中输入的依赖
在使用LogBack时,需要引入对应的jar包。主要依赖包括`logback-classic`、`logback-core`和`slf4j-api`。`logback-classic`是实现SLF4J接口的具体日志实现,`logback-core`包含了LogBack的基本功能,而`slf4j-api`则...
Logback 是一款广泛使用的日志记录框架,由 Ceki Gülcü 创建,作为其先前作品 Log4j 的改进版。这个压缩包包含了实现 Logback 功能所需的几个关键组件,以及一个配置文件,使得用户能够方便地管理和记录应用程序的...
Logback 使用 Logback 是一个流行的 Java 日志记录组件,由 log4j 的创始人 Ceki Gülcü 设计。Logback 当前分成三个模块:logback-core、logback-classic 和 logback-access。Logback 的核心对象包括 Appender、...
本文将深入探讨如何使用 Logback 实现日志打印和输出到指定位置。** 首先,我们需要理解 Logback 的核心组件:`Logger`、`Appender` 和 `Layout`。 1. **Logger**: 这是日志记录的入口点,你可以通过 `Logger` ...
**日志框架Logback简介** Logback 是一个用于日志记录的开源框架,由 Ceki Gülcü(也是 Log4j 的创始人)设计并开发。...对于开发者而言,理解和掌握 Logback 的使用能够提升应用程序的监控和调试能力。
**日志系统的重要性** ...通过深入理解和熟练使用Logback,我们可以优化日志记录,提升问题排查效率,为软件系统的稳定运行保驾护航。`logback-advance-demo`压缩包可能包含了上述功能的实践示例,供学习和参考。
Logback 是一个在 Java 应用程序中广泛使用的日志框架,由 Ceki Gülcü 创建,作为 Log4j 的继任者。它提供高效、灵活的日志记录功能,能够满足各种日志处理需求。本篇文章将详细介绍如何使用 logback,并着重讲解...
排版(Layout)是决定日志最终输出格式的关键组件,文档中详细解释了什么是Layout,以及如何在logback-classic和logback-access中配置和使用自定义layout。Layout中包括PatternLayout、转换符说明、格式修饰符、求值...