Log4j输出格式参数一览
2015-07-02 14:01
531 查看
Conversion Character | Effect |
---|---|
c | Used to output the category of the logging event. The category 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 category name will be printed. By default the category name is printed in full. For example, for the category name "a.b.c" the pattern %c{2} will output "b.c". |
C | Used to output the fully qualified class 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 "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass". WARNING Generating the caller class information is slow. Thus, use should be avoided unless execution speed is not an issue. |
d | Used to output the date of the logging event. The date conversion specifier may be followed by a date format specifier enclosed between braces. For example, %d{HH:mm:ss,SSS} or %d{dd MMM yyyy HH:mm:ss,SSS}. If no date format specifier is given then ISO8601 format is assumed. The date format specifier admits the same syntax as the time pattern string of the SimpleDateFormat. Although part of the standard JDK, the performance of SimpleDateFormatis quite poor. For better results it is recommended to use the log4j date formatters. These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying AbsoluteTimeDateFormat, DateTimeDateFormatand respectively ISO8601DateFormat. For example, %d{ISO8601} or %d{ABSOLUTE}. These dedicated date formatters perform significantly better than SimpleDateFormat. |
F | Used to output the file name where the logging request was issued. WARNING Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue. |
l | Used to output location information of the caller which generated the logging event. The location information depends on the JVM 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 and should be avoided unless execution speed is not an issue. |
L | Used to output the line number from where the logging request was issued. WARNING Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue. |
m | Used to output the application supplied message associated with the logging event. |
M | Used to output the method name where the logging request was issued. WARNING Generating caller location information is extremely slow and should be avoided unless execution speed is not an issue. |
n | Outputs the platform dependent line separator character or characters. This conversion character offers practically 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. |
p | Used to output the priority 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. |
t | Used to output 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 clientNumberis the key. The value in the MDC corresponding to the key will be output. See MDCclass for more details. |
% | The sequence %% outputs a single percent sign. |
相关文章推荐
- 编译android源码遇到的问题use BUILD_PREBUILT instead
- [前端] 内容拉伸(拖拽效果)
- Windows 与 Ubuntu 之间的文件共享——搭建Samba服务器
- js 事件监听,执行某操作
- Hibernate的10个常见面试问题及答案
- MAC 删除arp缓存的命令 arp -ad
- Android WebView中的JavaScript代码使用
- Hibernate操作Clob数据类型
- intent-filter 之 data 「scheme, host, port, mimeType, path, pathPrefix, path
- Python 模块之fabric
- ssh框架整合需要的jar包
- html页面高度自适应
- acd - 1216 - Beautiful People(DLIS)
- How-to: Resolve "Datanode denied communication with namenode because hostname cannot be resolved (ip
- uc/os-ii任务延时
- Android开发,Eclipse未自动创建MainActivity及main.xml?
- 本科生面试总结,以及offer选择
- GSAP学习(二)——载入
- 银行卡卡号验证
- 50款国外后期草地素材t