- 浏览: 109648 次
- 性别:
- 来自: 杭州
文章分类
最新评论
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 80221.iterate v.反复说;重做;[计]迭代 ['ɪt ... -
english words
2015-02-09 13:05 511718.commodity n.日用品, ... -
20150121steve01.txt
2015-01-25 14:41 160|||18|||greeting|||2015-01-2 ... -
English All Words
2015-01-24 13:46 11241.inventory n. 存货,存货清单;详细目录 ... -
steve201514_01.txt
2015-01-18 19:20 60|||39|||Introduction: Hi, ... -
english notification
2014-12-11 19:26 417Let me express my deepest grati ... -
3.Variety is the Surce of Creativity
2012-07-16 08:08 819No housing can be constructed ... -
2.Friends
2012-07-16 07:39 454Friends play an important rol ... -
1.Youth
2012-07-16 07:25 357Youth is not a time of life; ... -
动感英语24
2012-07-14 09:11 611You're the expert, I just wor ... -
动感英语23
2012-06-19 22:04 593freeze for a minute 停下现在干的 ... -
动感英语22
2012-06-16 22:01 721a rain check 改天 I can' ... -
动感英语21
2012-06-12 20:14 637Spill:to disclose or reveal p ... -
每日至少一句
2012-05-16 12:11 6452012-05-16: Although apparen ... -
中国白领最爱插的英文单词 今天你用了吗
2012-05-14 12:21 716沪江小编:职场中,白 ... -
business english
2012-04-19 08:58 6442012-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的早期版本中,...
针对Log4j 2 远程代码执行漏洞,需要用到的升级资源包,适用于maven资源库,包括log4j,log4j-core,log4j-api,log4j-1.2-api,log4j-jpa等全套2.15.0 maven资源库jar包。如果是maven本地仓库使用,需要将zip包解压...
分别有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...
### 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-...
总结,SLF4J和Log4j的组合使用让日志管理更加灵活,开发者可以通过SLF4J的简洁API进行日志记录,同时利用Log4j的强大功能,如自定义输出格式和多种输出目的地。通过适当的配置和测试,我们可以确保日志系统按照预期...
Apache log4j2零日漏洞,根据 log4j-2.15.0-rc2 版本编译生成log4j-api-2.15.0.jar 1.解压你的jar jar xvf XXX.jar 2. 删除旧版本jar cd ./BOOT-INF/lib rm -rf log4j-api-*.jar 3. 上传新版本log4j-api-2.15.0....
Log4j、Log4j2和Fastjson的安全性问题在过去曾引起广泛关注,例如Log4j2的CVE-2021-44228(也被称为Log4Shell漏洞),这是一个远程代码执行漏洞,影响了许多使用Log4j2的系统。这个插件可能就是为了检测和利用这些...
此次提及的`log4j-api-2.12.4.jar`和`log4j-core-2.12.4.jar`是Log4j 2框架的两个关键组件,版本号为2.12.4,这个版本主要修复了之前版本中可能存在的安全漏洞。 **log4j-api-2.12.4.jar** 是Log4j 2框架的API模块...
《深入理解Log4j 2.15.0-rc2:日志处理的关键技术解析》 Log4j,作为Java领域广泛使用的日志记录框架,一直以来都是开发者们的重要工具。这次我们关注的是其最新版本——logging-log4j2-log4j-2.15.0-rc2。这个版本...
Log4j和Log4j2是两种广泛使用的Java日志框架,它们提供了灵活的日志配置和高性能的日志处理能力。本文将详细介绍如何在SpringBoot项目中配置Log4j和Log4j2。 ### SpringBoot与Log4j Log4j是Apache的一个开源项目,...
**日志框架Log4j详解** 在Java开发中,日志记录是一项不可或缺的功能,它能够帮助开发者追踪程序运行状态,定位错误,优化性能,并为后期维护提供重要信息。Log4j是Apache组织开发的一个强大的、灵活的日志记录框架...
《log4j-2.18.0:修复重大安全漏洞的紧急更新》 在IT领域,安全性始终是首要关注的问题。近期,一个名为“log4j2”的严重安全漏洞引发了广泛关注,它影响了所有log4j2版本,从2.0开始直到2.18.0版本之前。这个漏洞...
Apache log4j2零日漏洞,根据 log4j-2.15.0-rc2 版本编译生成log4j-api-2.15.0.jar 1.解压你的jar jar xvf XXX.jar 2. 删除旧版本jar cd ./BOOT-INF/lib rm -rf log4j-api-*.jar 3. 上传新版本log4j-api-...
标题提及的是"log4j-API-最新稳定版本log4j-1.2.17",这表明我们关注的是日志框架Log4j的一个特定版本,即1.2.17。Log4j是Apache软件基金会开发的一个用于Java应用程序的日志记录工具,它提供了灵活的日志记录功能,...
总的来说,"logging-log4j2-log4j-2.16.0-rc1.zip"的发布是Log4j团队对"Log4Shell"漏洞的有力回应,通过禁用可能导致安全问题的功能,提高了整体的安全标准。这一事件提醒我们,安全无小事,及时的更新和维护是保障...
这个“log4j示例项目”旨在帮助开发者理解和使用Log4j,通过该项目,我们可以深入学习Log4j的配置、使用方法以及其在实际开发中的应用。 **1. Log4j的组成部分** Log4j主要包括三个核心组件:Logger(日志器)、...
《深入理解log4j-api-2.17.1.jar与log4j-core-2.17.1.jar》 在Java开发中,日志管理是不可或缺的一部分,它帮助我们跟踪程序运行状态、定位错误和调试问题。Log4j作为一款广泛使用的日志框架,历经多次迭代,现在...
Log4j 是一个日志记录框架,Log4j 2 是对 Log4j 的升级,提供了重大改进,超越其前身 Log4j 1.x,并提供许多其它现代功能 ,例如对标记的支持、使用查找的属性替换、lambda 表达式与日志记录时无垃圾等。 Apache ...