[size=small][b]1. 将prudent设置为true 是为了支持多个JVM往同一个日志文件写日志.[/b]

参考[url]http://logback.qos.ch/manual/appenders.html#FileAppender[/url]里面的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.

[b]2. SiftingAppender: logging different threads to different log files[/b]
[url]http://www.nurkiewicz.com/2013/04/siftingappender-logging-different.html[/url]

[b]Encoder and Layout-Pattern.[/b]
原文:[url]http://logback.qos.ch/codes.html#layoutInsteadOfEncoder[/url]
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.

[/size]

logback prudent, SiftingAppender, layout, encoder的使用相关推荐

  1. logback异常RuntimeException in Action for tag [encoder] java.lang.NumberFormatException

    我的配置文件: <?xml version="1.0" encoding="UTF-8"?> <configuration scan=&quo ...

  2. Logback 专题

    logback-spring.xml <?xml version="1.0" encoding="UTF-8"?> <configuratio ...

  3. logback使用配置详解

    1.介绍 Logback是由log4j创始人设计的另一个开源日志组件,它当前分为下面下个模块: logback-core:其它两个模块的基础模块 logback-classic:它是log4j的一个改 ...

  4. 阅读Logback文档笔记--Logback的Appender配置

    Logback将执行日志事件输出的组件称为Appender,实现的Appender必须继承 ch.qos.logback.core.Appender 接口 接口如下: package ch.qos.l ...

  5. Logback各Appender详解及配置

    转载自:http://blog.csdn.net/doraemon_wu/article/details/51972261 Logback将执行日志事件输出的组件称为Appender,实现的Appen ...

  6. Logback第四章:Appenders

    第四章:Appenders 什么是 Appender logback 将写入日志事件的任务委托给一个名为 appender 的组件.Appender 必须实现 ch.qos.logback.core. ...

  7. Logback中文文档(四):Appender

    什么是 Appender Appender是负责写记录事件的组件.Appender 必须实现接口"ch.qos.logback.core.Appender".该接口的重要方法总结如 ...

  8. logback节点配置详解

    logback节点配置详解 一:根节点 <configuration></configuration> 属性 : debug : 默认为false ,设置为true时,将打印出 ...

  9. Spring Boot 应用系列 5 -- Spring Boot 2 整合logback

    上一篇我们梳理了Spring Boot 2 整合log4j2的配置过程,其中讲到了Spring Boot 2原装适配logback,并且在非异步环境下logback和log4j2的性能差别不大,所以对 ...

最新文章

  1. Chrome开发,debug的使用方法。
  2. 为什么文件上传不了服务器上,文件上传存在服务器还是数据库
  3. 一年增加1.2w星,Dapr能否引领云原生中间件的未来?
  4. 计算机模拟人工录入,用计算机模拟交互式输入代替人工进行流程录入
  5. 【文末福利】图论算法:稳定婚姻问题,如何找到最适合自己的另一半
  6. UIActionSheet 多项弹出框
  7. 实现后台高级查询(高级版)
  8. covariance 公式_黑体辐射的近似公式
  9. vue3.0新特性及用法
  10. C语言中指针的数据类型小结
  11. 微信好友管理工具_助手_系统软件哪个最好?
  12. 计算机专业实习报告-5000字+,以及计算机专业实习周记-15篇
  13. powerDesign导出word操作步骤
  14. Leetcode第904题
  15. Hive(二):with as用法
  16. java面试(3)SQL优化
  17. 计算机专业留学申请经验介绍,[成功案例分析] 低GPA(70)如何成功申请到美国计算机(CS)研究生——经验总结...
  18. 宋家瑜:做中国的威睿而不是VMware中国
  19. windows8.1版本遇到安装wireshark报错KB2999226补丁的解决方案
  20. 一元多项式加法c语言,C语言一元多项式加法.doc

热门文章

  1. java.sql.SQLException: Streaming result set com.mysql.jdbc.RowDataDynamic@44f16719 is still active.
  2. 最快速的文件传输软件,解析镭速文件传输软件
  3. Android-Application被回收引发空指针异常分析(消灭全局变量)
  4. 教学相长——什么是真正的学习型人才
  5. HTML学生个人网站作业设计:电影网站设计——猫眼电影(9页) HTML+CSS+JavaScript 简单DIV布局个人介绍网页模板代码 DW学生个人网站制作成品下载
  6. 如何提升网站关键词排名
  7. 华为SNS交换机(OEM博科FC交换机)configupload无法使用ftp协议处理方法
  8. 裁判文书网爬虫Docid解密思路
  9. Elang 学习笔记(二)
  10. excel快速把公式应用到一整列