- 浏览: 112481 次
- 性别:
- 来自: 杭州
-
文章分类
最新评论
The first and foremost advantage of any logging API over plain System.out.println resides in
For example, the logger named "com.foo" is a parent of the logger named "com.foo.Bar". Similarly, "java" is a parent of "java.util" and an ancestor of "java.util.Vector". This naming scheme should be familiar to most developers.
By definition, the printing method determines the level of a logging request.
This rule is at the heart of log4j
The developer is free to name the loggers as desired
seems to be the best strategy known so far.
If in addition a file appender is added to a logger, say C, then enabled logging requests forC and C's children will print on a file and on the console.
More often than not, users wish to customize not only the output destination but also the output format.
The layout is responsible for formatting the logging request according to the user's wishes,
whereas an appender takes care of sending the formatted output to its destination
Just as importantly, log4j will render the content of the log message according to user specified criteria.
Inserting log requests into the application code requires a fair amount of planning and effort.
Observation shows that approximately 4 percent of code is dedicated to logging. Consequently, even moderately sized applications will have thousands of logging statements embedded within their code.
Let us give a taste of how this is done with the help of an imaginary application MyApp that uses log4j.
The figure below depicts the object diagram of MyApp after just having called the BasicConfigurator.configure method.
As a side note, let me mention that
For example, the logger named "com.foo" is a parent of the logger named "com.foo.Bar". Similarly, "java" is a parent of "java.util" and an ancestor of "java.util.Vector". This naming scheme should be familiar to most developers.
By definition, the printing method determines the level of a logging request.
This rule is at the heart of log4j
The developer is free to name the loggers as desired
seems to be the best strategy known so far.
If in addition a file appender is added to a logger, say C, then enabled logging requests forC and C's children will print on a file and on the console.
More often than not, users wish to customize not only the output destination but also the output format.
The layout is responsible for formatting the logging request according to the user's wishes,
whereas an appender takes care of sending the formatted output to its destination
Just as importantly, log4j will render the content of the log message according to user specified criteria.
Inserting log requests into the application code requires a fair amount of planning and effort.
Observation shows that approximately 4 percent of code is dedicated to logging. Consequently, even moderately sized applications will have thousands of logging statements embedded within their code.
Let us give a taste of how this is done with the help of an imaginary application MyApp that uses log4j.
The figure below depicts the object diagram of MyApp after just having called the BasicConfigurator.configure method.
As a side note, let me mention that
发表评论
-
english words
2015-09-01 18:18 81891.iterate v.反复说;重做;[计]迭代 ['ɪt ... -
english words
2015-02-09 13:05 526718.commodity n.日用品, ... -
20150121steve01.txt
2015-01-25 14:41 160|||18|||greeting|||2015-01-2 ... -
English All Words
2015-01-24 13:46 11371.inventory n. 存货,存货清单;详细目录 ... -
steve201514_01.txt
2015-01-18 19:20 60|||39|||Introduction: Hi, ... -
english notification
2014-12-11 19:26 427Let me express my deepest grati ... -
3.Variety is the Surce of Creativity
2012-07-16 08:08 835No housing can be constructed ... -
2.Friends
2012-07-16 07:39 461Friends play an important rol ... -
1.Youth
2012-07-16 07:25 373Youth is not a time of life; ... -
动感英语24
2012-07-14 09:11 630You're the expert, I just wor ... -
动感英语23
2012-06-19 22:04 610freeze for a minute 停下现在干的 ... -
动感英语22
2012-06-16 22:01 734a rain check 改天 I can' ... -
动感英语21
2012-06-12 20:14 667Spill:to disclose or reveal p ... -
每日至少一句
2012-05-16 12:11 6522012-05-16: Although apparen ... -
中国白领最爱插的英文单词 今天你用了吗
2012-05-14 12:21 727沪江小编:职场中,白 ... -
business english
2012-04-19 08:58 6862012-04-19 and so forth 等等 shed ...
相关推荐
Log4j只需要引入一个JAR包,即log4j.jar,而Log4j2则需要引入两个核心JAR包,即log4j-core.jar和log4j-api.jar。大家可以发现,Log4j和Log4j2的包路径是不同的,Apache为了区分,包路径都更新了。 文件渲染 Log4j...
Log4j是一个广泛使用的Java日志记录框架,它允许开发者在应用程序中轻松地记录各种级别的日志信息,如DEBUG、INFO、WARN、ERROR等。在2021年底,一个重大的安全漏洞(CVE-2021-44228)被发现在Log4j2的早期版本中,...
分别有disruptor-3.3.4.jar(Log4j2异步日志的底层实现)、log4j-api-2.19.0.jar(log4j门面)、log4j-core-2.19.0.jar(log4j实现)、log4j-slf4j-impl-2.19.0.jar(SLF4J与Log4j绑定)、slf4j-api-1.7.30.jar(SLF...
针对Log4j 2 远程代码执行漏洞,需要用到的升级资源包,适用于maven资源库,包括log4j,log4j-core,log4j-api,log4j-1.2-api,log4j-jpa等全套2.15.0 maven资源库jar包。如果是maven本地仓库使用,需要将zip包解压...
### Log4j2简介 Log4j2是Apache软件基金会推出的日志框架,它是Log4j 1.x的重构版本,旨在提供更为高效且灵活的日志解决方案。与Log4j 1.x相比,Log4j2在设计上进行了重大改进,并解决了Logback等其他日志框架中...
apache-log4j-1.2.15.jar, apache-log4j-extras-1.0.jar, apache-log4j-extras-1.1.jar, apache-log4j.jar, log4j-1.2-api-2.0.2-javadoc.jar, log4j-1.2-api-2.0.2-sources.jar, log4j-1.2-api-2.0.2.jar, log4j-...