`
semi_sleep
  • 浏览: 101480 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

20091105 (logging)

阅读更多

log4j


The inherited level for a given logger C, is equal to the first non-null level in the logger hierarchy, starting at C and proceeding upwards in the hierarchy towards the root logger.


The output of a log statement of logger C will go to all the appenders in C and its ancestors. This is the meaning of the term "appender additivity".
However, if an ancestor of logger C, say P, has the additivity flag set to false, then C's output will be directed to all the appenders in C and it's ancestors upto and including P but not the appenders in any of the ancestors of P.
Loggers have their additivity flag set to true by default.


The PatternLayout, part of the standard log4j distribution, lets the user specify the output format according to conversion patterns similar to the C language printf function.


BasicConfigurator


PropertyConfigurator


DOMConfigurator


static inializer of the Logger class
The exact default initialization algorithm is defined as follows:
Setting the log4j.defaultInitOverride system property to any other value then "false" will cause log4j to skip the default initialization procedure (this procedure).
Set the resource string variable to the value of the log4j.configuration system property. The preferred way to specify the default initialization file is through the log4j.configuration system property. In case the system property log4j.configuration is not defined, then set the string variable resource to its default value "log4j.properties".
Attempt to convert the resource variable to a URL.
If the resource variable cannot be converted to a URL, for example due to a MalformedURLException, then search for the resource from the classpath by calling org.apache.log4j.helpers.Loader.getResource(resource, Logger.class) which returns a URL. Note that the string "log4j.properties" constitutes a malformed URL. See Loader.getResource(java.lang.String) for the list of searched locations.
If no URL could not be found, abort default initialization. Otherwise, configure log4j from the URL. The PropertyConfigurator will be used to parse the URL to configure log4j unless the URL ends with the ".xml" extension, in which case the DOMConfigurator will be used. You can optionaly specify a custom configurator. The value of the log4j.configuratorClass system property is taken as the fully qualified class name of your custom configurator. The custom configurator you specify must implement the Configurator interface.


To uniquely stamp each request, the user pushes contextual information into the NDC, the abbreviation of Nested Diagnostic Context.
Use org.apache.log4j.NDC


对于log4j,priority level是由上至下继承的,但是log的propagate,包括appender却是由下至上的


properties config的前缀、层次
所有都以log4j开头
log4j.rootLogger/log4j.logger.xxx = [level], [appender]
log4j.appender.xxx = [appender class]
log4j.appender.xxx.layout = [layout class]
log4j.appender.xxx.yyy = [appender property value]


slf


All SLF4J adapters support formated log messages with significantly improved performace results.
logger.debug("Temperature set to {}. Old temperature was {}.", t, oldT);


The SLF4J distribution ships with several jar files slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-log4j13.jar, slf4j-jdk14.jar and slf4j-jcl.jar. Each of these jar files is hardwired at compile-time to use just one implementation.
As noted earlier, SLF4J does not rely on any special class loader machinery. Every variant of slf4j-<impl>.jar is statically hardwired at compile time to use one and only specific implementation. Thus, SLF4J suffers from none of the class loader problems observed when using JCL.


jcl104-over-slf4j.jar
To ease migration to SLF4J from JCL, recent SLF4J distributions include the jar file jcl104-over-slf4j.jar. This jar file is intended as a drop-in replacement for JCL version 1.0.4. It implements the public API of JCL but using SLF4J underneath, hence the name "JCL over SLF4J."


slf4j-jcl.jar
Some of our users after having switched to SLF4J API realize that in some contexts the use of JCL is mandatory and their use of SLF4J can be a problem.
The JCL binding will delegate all logging calls made through SLF4J API to JCL.


jcl104-over-slf4j.jar should not be confused with slf4j-jcl.jar
Please note that jcl104-over-slf4j.jar and slf4j-jcl.jar cannot be deployed at the same time. The former jar file will cause JCL to delegate the choice of the logging system to SLF4J and the latter jar file will cause SLF4J to delegate the choice of the logging system to JCL, resulting in an infinite loop.

分享到:
评论

相关推荐

    commons-logging.jar

    commons-logging-1.0-javadoc.jar, commons-logging-1.0.1-javadoc.jar, commons-logging-1.0.1.jar, commons-logging-1.0.2-javadoc.jar, commons-logging-1.0.2.jar, commons-logging-1.0.3-javadoc.jar, commons-...

    commons-logging-1.2_commonslogging_

    《Spring框架中的日志工具:Apache Commons Logging 1.2》 Apache Commons Logging(简称Commons Logging)是Apache软件基金会开发的一个开源项目,它提供了一个轻量级的日志API,旨在为Java应用程序提供一个简单的...

    python的logging模块

    ### Python的logging模块详解 #### 一、简介与应用场景 在进行Python开发时,日志模块是必不可少的一部分,尤其对于大型或复杂的项目来说更是如此。Python内置的`logging`模块提供了一种简单且灵活的方式来记录...

    jboss-logging-3.3.2.Final-API文档-中文版.zip

    赠送jar包:jboss-logging-3.3.2.Final.jar; 赠送原API文档:jboss-logging-3.3.2.Final-javadoc.jar; 赠送源代码:jboss-logging-3.3.2.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.3.2.Final....

    jboss-logging-3.4.1.Final-API文档-中文版.zip

    赠送jar包:jboss-logging-3.4.1.Final.jar; 赠送原API文档:jboss-logging-3.4.1.Final-javadoc.jar; 赠送源代码:jboss-logging-3.4.1.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.4.1.Final....

    jboss-logging-3.4.3.Final-API文档-中文版.zip

    赠送jar包:jboss-logging-3.4.3.Final.jar; 赠送原API文档:jboss-logging-3.4.3.Final-javadoc.jar; 赠送源代码:jboss-logging-3.4.3.Final-sources.jar; 赠送Maven依赖信息文件:jboss-logging-3.4.3.Final....

    Commons logging API.chm

    Commons-logging API apache Commons logging API

    Common Logging的jar包.zip

    Commons Logging是Apache软件基金会开发的一个Java日志接口库,它的主要目的是为Java应用程序提供一个简单而统一的日志记录接口,使得开发者可以在不修改代码的情况下切换不同的日志实现。这个库被称为“Commons ...

    commons-logging-1.1.3.jar

    common-logging是apache提供的一个通用的日志接口。用户可以自由选择第三方的日志组件作为具体实现,像log4j,或者jdk自带的logging, common-logging会通过动态查找的机制,在程序运行时自动找出真正使用的日志库。...

    common-logging1.1.1jar

    《全面解析Apache Commons Logging 1.1.1》 Apache Commons Logging(简称Commons Logging)是Java领域中广泛使用的日志记录工具包,它提供了一个轻量级的日志接口,允许开发者在不修改代码的情况下更换底层的日志...

    commons-logging-1.2-bin.zip下载

    Apache Commons Logging 是一个Java日志框架的抽象层,它允许开发者在不同的日志实现之间进行切换,而无需修改代码。这个"commons-logging-1.2-bin.zip"压缩包包含了Apache Commons Logging库的1.2版本,这是一个...

    commons-logging-1.2.jar

    《Apache Commons Logging与Spring框架的紧密关系》 Apache Commons Logging(简称Commons Logging)是Apache软件基金会的一个项目,提供一个简单、统一的API,用于在Java应用程序中进行日志记录。这个库允许开发者...

    commons-logging-1.2

    Commons Logging 是 Apache 组织提供的一款轻量级的日志记录工具库,它的主要目标是为 Java 开发者提供一个简单的接口来使用各种日志框架,如 Log4j、Java Util Logging(JUL)或者 Simple Logging Facade for Java...

    commons-logging-1.2.JAR开源包

    《Apache Commons Logging详解》 Apache Commons Logging,简称为Commons Logging,是Apache软件基金会开发的一个开源日志框架,主要用于提供一个统一的日志API,让开发者能够在不改变代码的情况下,自由切换不同的...

    commons-logging-1.2源码(commons-logging-1.2-src.zip)

    《Apache Commons Logging 1.2源码解析》 Apache Commons Logging(简称Commons Logging)是Apache软件基金会开发的一个日志接口库,它提供了一个统一的日志API,允许开发者选择底层的日志实现,如Log4j、Java内置...

    python改变日志(logging)存放位置的示例

    实现了简单版本的logging.config,支持一般的通过config文件进行配置。感觉还有更好的方法,是直接利用logging.config.fileConfig(log_config_file)方式读进来之后,通过修改handler方式来进行修改。 复制代码 代码...

    spring-framework & commons-logging

    spring-framework & commons-logging spring-framework & commons-logging spring-framework & commons-logging spring-framework & commons-logging spring-framework & commons-logging spring-framework & ...

    commons-logging-1.0.4.jar 免费下载

    Commons Logging 是一个 Java 平台上的日志抽象层库,由 Apache 软件基金会开发。这个库的主要目的是为各种不同的日志框架提供一个统一的接口,使得开发者可以在不更改代码的情况下切换不同的日志实现。在给定的标题...

    Apache Commons-logging使用实例

    Apache Commons-logging 使用实例 Apache Commons-logging 是一个流行的Java日志记录库,提供了一个轻量级的日志记录接口,允许开发者使用不同的日志实现工具。下面是对 Apache Commons-logging 的使用实例的详细...

Global site tag (gtag.js) - Google Analytics