ConversionPattern 解析
Sample
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] %X{auth} - Line:%L %m%n" />
%m(message):输出的日志消息
%n(new line):換行
%d(datetime):输出当前语句运行的时刻
%r(run time):输出程序从运行到执行到当前语句时消耗的毫秒数
%t(thread id):当前语句所在的线程ID
%p(priority): 日志的当前优先级别,即DEBUG、INFO、WARN…等
%c(class):当前日志对象的名称
%L:输出语句所在的行号
%F:输出语句所在的文件名
%-数字:表示该项的最小长度,如果不够,则用空格填充
%X:mdc
%x:ndc
官方文档
http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html
|
Conversion Pattern Name |
Effect |
|
a |
Equivalent to appdomain |
|
appdomain |
Used to output the friendly name of the AppDomain where the logging event was generated. |
|
aspnet-cache |
Used to output all cache items in the case of %aspnet-cache or just one named item if used as %aspnet-cache{key} This pattern is not available for Compact Framework or Client Profile assemblies. |
|
aspnet-context |
Used to output all context items in the case of %aspnet-context or just one named item if used as %aspnet-context{key} This pattern is not available for Compact Framework or Client Profile assemblies. |
|
aspnet-request |
Used to output all request parameters in the case of %aspnet-request or just one named param if used as %aspnet-request{key} This pattern is not available for Compact Framework or Client Profile assemblies. |
|
aspnet-session |
Used to output all session items in the case of %aspnet-session or just one named item if used as %aspnet-session{key} This pattern is not available for Compact Framework or Client Profile assemblies. |
|
c |
Equivalent to logger |
|
C |
Equivalent to type |
|
class |
Equivalent to type |
|
d |
Equivalent to date |
|
date |
Used to output the date of the logging event in the local time zone. To output the date in universal time use the %utcdate pattern. The date conversion specifier may be followed by a date format specifier enclosed between braces. For example, %date{HH:mm:ss,fff}or %date{dd MMM yyyy HH:mm:ss,fff}. If no date format specifier is given then ISO8601 format is assumed (Iso8601DateFormatter). The date format specifier admits the same syntax as the time pattern string of theToString. For better results it is recommended to use the log4net date formatters. These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifyingAbsoluteTimeDateFormatter, DateTimeDateFormatter and respectivelyIso8601DateFormatter. For example, %date{ISO8601} or %date{ABSOLUTE}. These dedicated date formatters perform significantly better than ToString. |
|
exception |
Used to output the exception passed in with the log message. If an exception object is stored in the logging event it will be rendered into the pattern output with a trailing newline. If there is no exception then nothing will be output and no trailing newline will be appended. It is typical to put a newline before the exception and to have the exception as the last data in the pattern. |
|
F |
Equivalent to file |
|
file |
Used to output the file name where the logging request was issued. WARNING Generating caller location information is extremely slow. Its use should be avoided unless execution speed is not an issue. See the note below on the availability of caller location information. |
|
identity |
Used to output the user name for the currently active user (Principal.Identity.Name). WARNING Generating caller information is extremely slow. Its use should be avoided unless execution speed is not an issue. |
|
l |
Equivalent to location |
|
L |
Equivalent to line |
|
location |
Used to output location information of the caller which generated the logging event. The location information depends on the CLI implementation but usually consists of the fully qualified name of the calling method followed by the callers source the file name and line number between parentheses. The location information can be very useful. However, its generation is extremely slow. Its use should be avoided unless execution speed is not an issue. See the note below on the availability of caller location information. |
|
level |
Used to output the level of the logging event. |
|
line |
Used to output the line number from where the logging request was issued. WARNING Generating caller location information is extremely slow. Its use should be avoided unless execution speed is not an issue. See the note below on the availability of caller location information. |
|
logger |
Used to output the logger of the logging event. The logger conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets. If a precision specifier is given, then only the corresponding number of right most components of the logger name will be printed. By default the logger name is printed in full. For example, for the logger name "a.b.c" the pattern %logger{2} will output "b.c". |
|
m |
Equivalent to message |
|
M |
Equivalent to method |
|
message |
Used to output the application supplied message associated with the logging event. |
|
mdc |
The MDC (old name for the ThreadContext.Properties) is now part of the combined event properties. This pattern is supported for compatibility but is equivalent to property. |
|
method |
Used to output the method name where the logging request was issued. WARNING Generating caller location information is extremely slow. Its use should be avoided unless execution speed is not an issue. See the note below on the availability of caller location information. |
|
n |
Equivalent to newline |
|
newline |
Outputs the platform dependent line separator character or characters. This conversion pattern offers the same performance as using non-portable line separator strings such as "\n", or "\r\n". Thus, it is the preferred way of specifying a line separator. |
|
ndc |
Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event. |
|
p |
Equivalent to level |
|
P |
Equivalent to property |
|
properties |
Equivalent to property |
|
property |
Used to output the an event specific property. The key to lookup must be specified within braces and directly following the pattern specifier, e.g. %property{user} would include the value from the property that is keyed by the string 'user'. Each property value that is to be included in the log must be specified separately. Properties are added to events by loggers or appenders. By default the log4net:HostName property is set to the name of machine on which the event was originally logged. If no key is specified, e.g. %property then all the keys and their values are printed in a comma separated list. The properties of an event are combined from a number of different contexts. These are listed below in the order in which they are searched. the event properties The event has Properties that can be set. These properties are specific to this event only. the thread properties The Properties that are set on the current thread. These properties are shared by all events logged on this thread. the global properties The Properties that are set globally. These properties are shared by all the threads in the AppDomain. |
|
r |
Equivalent to timestamp |
|
stacktrace |
Used to output the stack trace of the logging event The stack trace level specifier may be enclosed between braces. For example, %stacktrace{level}. If no stack trace level specifier is given then 1 is assumed Output uses the format: type3.MethodCall3 > type2.MethodCall2 > type1.MethodCall1 This pattern is not available for Compact Framework assemblies. |
|
stacktracedetail |
Used to output the stack trace of the logging event The stack trace level specifier may be enclosed between braces. For example, %stacktracedetail{level}. If no stack trace level specifier is given then 1 is assumed Output uses the format: type3.MethodCall3(type param,...) > type2.MethodCall2(type param,...) > type1.MethodCall1(type param,...) This pattern is not available for Compact Framework assemblies. |
|
t |
Equivalent to thread |
|
timestamp |
Used to output the number of milliseconds elapsed since the start of the application until the creation of the logging event. |
|
thread |
Used to output the name of the thread that generated the logging event. Uses the thread number if no name is available. |
|
type |
Used to output the fully qualified type name of the caller issuing the logging request. This conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets. If a precision specifier is given, then only the corresponding number of right most components of the class name will be printed. By default the class name is output in fully qualified form. For example, for the class name "log4net.Layout.PatternLayout", the pattern %type{1}will output "PatternLayout". WARNING Generating the caller class information is slow. Thus, its use should be avoided unless execution speed is not an issue. See the note below on the availability of caller location information. |
|
u |
Equivalent to identity |
|
username |
Used to output the WindowsIdentity for the currently active user. WARNING Generating caller WindowsIdentity information is extremely slow. Its use should be avoided unless execution speed is not an issue. |
|
utcdate |
Used to output the date of the logging event in universal time. The date conversion specifier may be followed by a date format specifier enclosed between braces. For example, %utcdate{HH:mm:ss,fff} or %utcdate{dd MMM yyyy HH:mm:ss,fff}. If no date format specifier is given then ISO8601 format is assumed (Iso8601DateFormatter). The date format specifier admits the same syntax as the time pattern string of theToString. For better results it is recommended to use the log4net date formatters. These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifyingAbsoluteTimeDateFormatter, DateTimeDateFormatter and respectivelyIso8601DateFormatter. For example, %utcdate{ISO8601} or%utcdate{ABSOLUTE}. These dedicated date formatters perform significantly better than ToString. |
|
w |
Equivalent to username |
|
x |
Equivalent to ndc |
|
X |
Equivalent to mdc |
|
% |
The sequence %% outputs a single percent sign. |
ConversionPattern 解析的更多相关文章
- 【转载】[C#]Log4net中的RollingFileAppender解析
Log4日志组件的应用确实简单实用,在比较了企业库和Log4的日志功能后,个人觉得Log4的功能更加强大点.补充说明下,我使用的企业库是2.0版本,Log4net是1.2.1版本的. 在Log4net ...
- 使用jsonpath解析json内容
JsonPath提供的json解析非常强大,它提供了类似正则表达式的语法,基本上可以满足所有你想要获得的json内容.下面我把官网介绍的每个表达式用代码实现,可以更直观的知道该怎么用它. 一.首先需要 ...
- springmvc 项目完整示例06 日志–log4j 参数详细解析 log4j如何配置
Log4j由三个重要的组件构成: 日志信息的优先级 日志信息的输出目的地 日志信息的输出格式 日志信息的优先级从高到低有ERROR.WARN. INFO.DEBUG,分别用来指定这条日志信息的重要程度 ...
- log4j源码解析-文件解析
承接前文log4j源码解析,前文主要介绍了log4j的文件加载方式以及Logger对象创建.本文将在此基础上具体看下log4j是如何解析文件并输出我们所常见的日志格式 附例 文件的加载方式,我们就选举 ...
- slf4j和log4j源代码解析以及详解
备注:下面所有代码以log4j为例 包结构 slf4j-api.jar对外提供api slf4j.log4j12.jar提供适配器 log4j.jar是log4j的jar slf4j初始化 获取ILo ...
- Log4j:log4j.properties 配置解析
Log4j 三个主要组件 Loggers(记录器):记录日志的工具,程序中就是用它来记录我们想要的日志信息. Appenders (输出源):日志输出到什么地方,可以是控制台.文件.流位置.数据库,等 ...
- Java日志实战及解析
Java日志实战及解析 日志是程序员必须掌握的基础技能之一,如果您写的软件没有日志,可以说你没有成为一个真正意义上的程序员. 为什么要记日志? • 监控代码 • 变量变化情况, ...
- log4j详细配置解析
出自:http://www.blogjava.net/zJun/archive/2006/06/28/55511.html Log4J的配置文件(Configuration File)就是用来设置记录 ...
- Mybatis源码解析,一步一步从浅入深(一):创建准备工程
Spring SpringMVC Mybatis(简称ssm)是一个很流行的java web框架,而Mybatis作为ORM 持久层框架,因其灵活简单,深受青睐.而且现在的招聘职位中都要求应试者熟悉M ...
随机推荐
- 淘宝(阿里百川)手机客户端开发日记第二篇 android首页之顶部轮播特效制作 (二)
1.我们来设计flash_slide.xml 布局,这个xml主要做成模块化,方便其它的activity可以动态去调用. flash_slide.xml内容如下: <?xml version=& ...
- Mysql跨平台(Windows,Linux,Mac)使用与安装
MySQL其实是一个跨平台的轻量级数据库,平时开发会用到很多.有写程序可能要跨平台开发,接下来我就介绍一下如何跨平台使用Mysql. 这里所谓的跨平台就是Windows,Linux,Mac共同用一套M ...
- ubuntu下git输出的颜色变化
(这些文章都是从我的个人主页上粘贴过来的,大家也可以访问我的主页 www.iwangzheng.com) 11点进家门,感觉很温暖哦. 以下是如何在用git的时候清晰的看出关键字的方法. $ vim ...
- Leetcode 之Validate Binary Search Tree(53)
判断是否是有效的二叉搜索树,即左子树的值小于根结点,右子树的值大于根结点.可以采用递归的方式来完成,递归时如何 传递有效的参数与根结点进行比较,是此题的难点. bool isValidBST(Tree ...
- petri网学习心得
本文转载自duxw,如给您带来不便之处,请联系博主. 1.Petri网书籍:<petri网导论>,吴哲辉 非常适合初学者.概念清晰,容易理解. 2.工作流书籍:<Workflow M ...
- eclipse加速之禁用JS、jsp等文件的语法验证,eclipsejs
eclipse加速之禁用JS.jsp等文件的语法验证 去除eclipse的JS验证:将windows->preference->Java Script->Validator-> ...
- 【转】基于注解的SpirngMVC简单介绍
转载地址:http://haohaoxuexi.iteye.com/blog/1343761 SpringMVC是一个基于DispatcherServlet的MVC框架,每一个请求最先访问的都是 Di ...
- kettle使用log4j管理输出日志
在使用kettle进行数据分析和清洗时日志非常多而且杂乱,使用原有的日志有时找不到异常的位置,有时日志不够详细,说简单一点就是日志不是我们想要的.因而对kettle日志进行相应的管理就想得尤为重要了. ...
- 【好用的小技巧】win8兼容、网页不让复制
1.今天下了个matlab7,我用的是win8系统,不兼容. 解决:鼠标右键matlab7的快捷键,点击属性,选择兼容性,选择window vista即可运行 2.在一个 网页上看到一个对自己很有帮助 ...
- 支持向量机(SVM)简介
主要内容 一:SVM简介 二:线性分类 三:分类间隔 四:核函数 五:松弛变量 SVM简介 支持向量机(support vector Machine)是由Cortes和Vapnik于1995年首先提出 ...