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, it's 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 SimpleDateFormat is 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 ,DateTimeDateFormat and 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. It's use 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, it's generation is extremely slow. It's use 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. It's use 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. It's use 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 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. |
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.
See MDC class for more details.
|
% |
The sequence %% outputs a single percent sign. |
分享到:
相关推荐
根据项目需要,要求日志文件名及输出的日志内容头为特殊的格式,因此重写了log4j的一些方法,如要求的格式和项目不同,可根据示例参考进行再次的修改
针对公司的日志标准进行log4j的方法重写,如想了解详细内容,可访问如下连接地址:https://blog.csdn.net/SongYou05/article/details/80008742。
Log4J 日志文件输出Demo
参照了几个网上大神配置,部分教程的描述有误,最终调试完成,可以实现kettle日志输出,测试版本...需要替换的文件为,Kettle的程序目录下data-integration-6.0\plugins\kettle5-log4j-plugin中有一个log4j.xml文件。
log4j 配置 输出日志到控制台 到文件 代码及案例方便学习
禁用与使用日志请求只是Log4j其中的一个小小的地方,Log4j日志系统允许把日志输出到不同的地方,如控制台(Console)、文件(Files)、根据天数或者文件大小产生新的文件、以流的形式发送到其它地方等等。...
本工程以一个简单的log4j示例演示了log4j的使用方法 本工程编码方式:UTF-8 本工程开发工具:MyEclipse 说明:log4j详细使用方法请参考博客:http://blog.csdn.net/gaohuanjie/article/details/44077551
设置log4j的根目录,值为 日志等级(DEBUG,INFO,WARN,ERROR,FATAL) , 输出目标名称 log4j.rootLogger=DEBUG,A1 设置输出方式,常用的有: ConsoleAppender 在控制器中输出信息 RollingFileApperder 在文件中输出...
log4j按功能保存日志
Log4j2实现不同线程不同级别日志输出到不同的文件中 源码+log4j jar包
使用log4j2实现日志数据脱敏
文件中内容包括模块中某个类单独输出到一个日志文件中、模块中某个package单独输出到一个日志文件中、同一模块不同package输出到一个日志文件中三种情况下log4j.properties配置项配置事例、Java类中代码如何一致编写...
log4j、日志输出、自定义日志、多文件输出。
log4j2配置文件,按照文件大小划分日志,保存日期天数内的日志,指纹日志命名规则,日志输出等级等功能
log4j配置中的输出格式化符号详细说明
实际项目中经常会用到日志打印 为避免日志打印输出文件过大 消耗服务器内存 需要限制大小
主要介绍了SSM整合中的Log4j的配置详情,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
mybatis,log4j打印日志到后台和文件
日志打印文件log4j日志打印文件log4j日志打印文件log4j日志打印文件log4j日志打印文件log4j
演示了java记录通过log4j2记录日志到mysql数据库中