`

log4j

 
阅读更多
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
分享到:
评论

相关推荐

    老生常谈Log4j和Log4j2的区别(推荐)

    Log4j只需要引入一个JAR包,即log4j.jar,而Log4j2则需要引入两个核心JAR包,即log4j-core.jar和log4j-api.jar。大家可以发现,Log4j和Log4j2的包路径是不同的,Apache为了区分,包路径都更新了。 文件渲染 Log4j...

    若依框架使用的log4j2.16.0,修复log4j漏洞log4j2下载最新log4j2.16.0下载

    Log4j是一个广泛使用的Java日志记录框架,它允许开发者在应用程序中轻松地记录各种级别的日志信息,如DEBUG、INFO、WARN、ERROR等。在2021年底,一个重大的安全漏洞(CVE-2021-44228)被发现在Log4j2的早期版本中,...

    Log4j2学习用到的jar包及apache-log4j-2.19.0-bin.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...

    logging-log4j2-log4j-2.15.0-rc2.zip maven 资源库

    针对Log4j 2 远程代码执行漏洞,需要用到的升级资源包,适用于maven资源库,包括log4j,log4j-core,log4j-api,log4j-1.2-api,log4j-jpa等全套2.15.0 maven资源库jar包。如果是maven本地仓库使用,需要将zip包解压...

    Log4j2简介及与Log4j效率对比

    ### Log4j2简介 Log4j2是Apache软件基金会推出的日志框架,它是Log4j 1.x的重构版本,旨在提供更为高效且灵活的日志解决方案。与Log4j 1.x相比,Log4j2在设计上进行了重大改进,并解决了Logback等其他日志框架中...

    log4j.jar各个版本

    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-...

Global site tag (gtag.js) - Google Analytics