Log4j 与 Logback的ConversionPattern对比
为了能将log4j的配置无缝转到logback,需要了解其中ConversionPattern的差异,以下是对比表格,内容来自:
其中可能需要转换的地方主要有两块:
- %l
- %x
Log4j | Log4j Description | Logback | Logback Description |
---|---|---|---|
c | Used to output the category of the logging event. | c{length} / lo{length} / logger{length} | Outputs the name of the logger at the origin of the logging event. |
C | Used to output the fully qualified class name of the caller issuing the logging request | C{length} class{length} | Outputs the fully-qualified class name of the caller issuing the logging request. |
d | Used to output the date of the logging event. | d{pattern} / date{pattern} / d{pattern, timezone} / date{pattern, timezone} | Used to output the date of the logging event. |
F | Used to output the file name where the logging request was issued. | F / file | Outputs the file name of the Java source file where the logging request was issued. |
l |
Used to output location information of the caller which generated the logging event. | caller{depth} / caller{depth, evaluator-1, ... evaluator-n} | Outputs location information of the caller which generated the logging event. |
L | Used to output the line number from where the logging request was issued. | L / line | Outputs the line number from where the logging request was issued. |
m | Used to output the application supplied message associated with the logging event. | m / msg / message | Outputs the application-supplied message associated with the logging event. |
M | Used to output the method name where the logging request was issued. | M / method | Outputs the method name where the logging request was issued. |
n | Outputs the platform dependent line separator character or characters. | n | Outputs the platform dependent line separator character or characters. |
p | Used to output the priority of the logging event. | p / le / level | Outputs the level of the logging event. |
r | Used to output the number of milliseconds elapsed from the construction of the layout until the creation of the logging event. | r / relative | Outputs the number of milliseconds elapsed since the start of the application until the creation of the logging event. |
t | Used to output the name of the thread that generated the logging event. | t / thread | Outputs the name of the thread that generated the logging event. |
x |
Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event. | ||
X | Used to output the MDC (mapped diagnostic context) associated with the thread that generated the logging event. The X conversion character must be followed by the key for the map placed between braces, as in %X{clientNumber} where clientNumber is the key. The value in the MDC corresponding to the key will be output. | X{key:-defaultVal} / mdc{key:-defaultVal} | Outputs the MDC (mapped diagnostic context) associated with the thread that generated the logging event. |
% | The sequence %% outputs a single percent sign. |
Log4j 与 Logback的ConversionPattern对比的更多相关文章
- Log4j 与 logback对比、及使用配置
二.参考文档 1.Log4j 与 logback对比.及使用配置
- manven springmvc 项目中 slf4j 的配置使用(结合log4j 或者 logback)
前言:每个maven springmvc 都应该有日志功能,SLF4J(Simple logging facade for Java)就是一种日志规范,它提供了一个共通接口,可以适配多种不同的LOG实 ...
- Java日志框架 (commons-logging,log4j,slf4j,logback)
转自:http://blog.csdn.net/kobejayandy/article/details/17335407 如果对于commons-loging.log4j.slf4j.LogBack等 ...
- Log4j与Logback
一.Log4j简介: 1.Log4j(log for java) 01.是apache的一个开源项目 02.是使用java语言编写的一个日志框架 03.用于记录程序中的日志信息 04.可以将日志信息输 ...
- Java日志记录--log4j and logback
问题的引入: 把所有的信息打印在控制台上不行吗? 01.控制台有行数限制: 02.System.out.println()影响系统性能: 03.如果我们需要对一些用户的行为习惯进行分析,我们找不到用户 ...
- 【Java】日志知识总结和经常使用组合配置(commons-logging,log4j,slf4j,logback)
Log4j Apache的一个开放源码项目,通过使用Log4j,我们能够控制日志信息输送的目的地是控制台.文件.GUI组件.甚至是套接口服务 器.NT的事件记录器.UNIX Syslog守护进程等.用 ...
- Log4j,Log4j2,logback,slf4j日志学习
日志学习笔记 Log4j Log4j是Apache的一个开放源代码项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台.文件.数据库等:我们也可以控制每一条日志的输出格式:通过定义每一条 ...
- SLF4J其实只是一个门面服务而已,他并不是真正的日志框架,真正的日志的输出相关的实现还是要依赖Log4j、logback等日志框架的。
小结: 1.加层: 每一种日志框架都有自己单独的API,要使用对应的框架就要使用其对应的API,这就大大的增加应用程序代码对于日志框架的耦合性. 为了解决这个问题,就是在日志框架和应用程序之间架设一个 ...
- log4j和logback
Log4j和logback Log4j简介 Log4j(log for java) 1.是Apache的一个开源项目: 2.是使用Java语言编写的一个日志框架: 3.用于记录程序中的日志信息: 4. ...
随机推荐
- Vim命令合集
1.模式切换 三种模式:命令模式,输入模式,底行模式 命令模式与输入模式之间的切换:i esc 命令模式与底行模式的切换:shift + : esc 2. 插入 i:在当前字符的左边插入 I:在当前 ...
- 破解excel密码保护
破解excel密码保护 录制一个新宏.内容如下.保存后运行,点几次确定,过一分钟还会再弹出来,再点确定,然后就好了. Public Sub AllInternalPasswords() ' Break ...
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
在ViewPager中,用Fragment显示页面时,报错: java.lang.IllegalStateException: The specified child already has a pa ...
- as3自定义事件
package EventPackage { import flash.events.Event; /** * * @author tqr <br /> * 创建时间:2015-2-6 下 ...
- JavaWeb 学习001-登录页面-Servlet
那什么是Servlet呢? 我理解的Servlet 就是一个中间媒介,jsp页面原本需要一些操作,但是现在让jsp页面只是显示就好,把操作的工程转移给Servlet中. 使用Servlet时候有个固定 ...
- AndroidSQLite多出一个(db.journal文件原因)
今天在Android开发中中将sqlite的数据库创建之后,发现生成的.db文件的旁边 生成了一个大小为0的与数据库文件同名的.db-journal文件,不明白此文件的用途,于是 google了sql ...
- new与malloc
首先将new与malloc的区别总结如下: 1 new可以自动计算需要分配多大的内存,而malloc必须指明. 2 new返回的指针是有类型的,malloc返回void*类型的指针. 3 new在分配 ...
- linux环境下配置solr5.3详细步骤
本人上周五刚刚配置了一遍centos下配置solr5.3版本,综合借鉴并改进了一些教程,贴出如下 单位使用内网,本教程暂无截图,抱歉 另,本人是使用.net编程调用solr的使用的是solrnet,在 ...
- NDB Cluster 存储引擎物理备份
NDB Cluster 存储引擎物理备份NDB Cluster 存储引擎也是一款事务性存储引擎,和Innodb 一样也有redo 日志.NDBCluter 存储引擎自己提供了备份功能,可以通过相关的命 ...
- 插入排序 - C语言
插入排序的思想: 以现有的已排序元素为基础,下一个元素添加到正确的位置,则最终会完成排序. 第一个元素本身是已经排序好的.从第二个开始排. void insertSort(int arr[], int ...