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

Java Logging Techniques Summary(Introduction in Brief)

阅读更多

1. As the time evolves, many logging techniques emerged.

    1) java.util.logging (JUL) is provided by SUN along with JDK.

    2) org.apache.log4j (Log4j) is provided by ASF.

         -> Log4j-1.X and Log4j-2.X

         -> But most projects are using Log4j-1.X

    3) logback

    4) org.apache.commons.logging (JakartaCommonsLogging) is provided by ASF

    5) org.slf4j (SLF4J) is provided by SimpleLoggingFacade

 

2. Why do we use log and not System.out.println()?

    1) SYSOUT is not controlable.

        --> What if we want to output these information into file or other position?

        --> What if we don't want all of these information to be printed? 

        --> What if we want the information to be partially printed according to theirs severe level? 

    2) SYSOUT is not tracable

        --> If you are writing a java application server then only way to know what your server is doing is by seeing log file of your server. suppose you don't write anything in your java log file then no body knows what your sever is doing, it becomes increasingly important if your application is connected to upstream and downstream like in many stock trading systems or electronic trading system and get input from upstream , transforms and normalize it and send down to downstream. In case of any issue without java logs you won't be able to figure out what went wrong. That’s why logging in java is most important while writing any java server application. Logging in Java is not by choice it’s must to understand

    3) So logging techniques have emerged to solve these problems.

        --> They provide different severe level when output.

        --> They provide different handlers/appenders for the position of information.

        --> They are tracable.

 

3. Brief Comparasion of these techniques 

    1) Both Log4j, JUL and Logback are concrete implementations for logging. 

        --> But Log4j is more effecient and more functional than JUL .

    2) Both commons-logging and slf4j are interfaces for logging.

        --> The core target of these interfaces is to provide a simple and common standard for logging.


 

    3) Diagrams in details


 

4. Brief Introduction to JUL and Log4j

    1) JUL

        1) Provided along with JDK.

        2) Core function is provided with LogManager

        3) Below is the detailed work flow of JUL

     2) Log4j

        1) Provided by ASF and has a long history.

        2) The simple work flow of Log4j is as below


 

5. Brief Introduction to JCL and SLF4J

    0) The benefits of using logging-frameworks:

         --> Frameworks themselves didn't provide concrete logging function. They provided interfaces instead.

         --> The real logging function is based on Log4j or JUL.

         --> The deployer can decide which logging system to use, Log4j or JUL or others.

         --> The deployer can easily change the logging system without change the code as the interface stays the same.

    1) JCL


    2) SLF4J


 

6. Summary:

    1) By convention, many projects don't use JUL.

    2) They are using Log4j and JCL as combination.

    3) Or we can use Log4j and SLF4J as combination.

    3) The new trend is using Logback and SLF4J as combination.

 

Reference Links:

    1) http://mike.vanvendeloo.net/2011/05/06/logging-which-framework-to-choose-log4j-commons-logging-logback-slf4j

    2) http://www.tutorialspoint.com/log4j/log4j_architecture.htm

    3) http://aofengblog.blog.163.com/blog/static/631702120113249403464/

    4) http://webx.taobao.org/docs/logging.html

    5) http://javarevisited.blogspot.hk/2011/05/top-10-tips-on-logging-in-java.html

 

  • 大小: 32.4 KB
  • 大小: 22.8 KB
  • 大小: 24.7 KB
  • 大小: 76 KB
  • 大小: 513.4 KB
  • 大小: 68.7 KB
  • 大小: 88.9 KB
分享到:
评论

相关推荐

    java logging

    Java日志记录(Java Logging)是Java开发中的一个重要组成部分,主要用于收集、管理和处理应用程序的运行时信息。在Java中,日志系统可以帮助开发者追踪错误、调试代码、监控系统性能以及记录用户活动,对于理解和...

    java.util.logging.Logger使用详解

    ### Java.util.logging.Logger 使用详解 #### 一、创建Logger对象 在Java中,`java.util.logging.Logger` 是标准的日志框架之一,它提供了基础的日志记录功能。为了使用这一功能,首先需要获得 `java.util.logging...

    Java Logger Logging 封装

    `Logger`是Java标准库`java.util.logging`包提供的日志工具,它提供了多种级别的日志记录,如`SEVERE`、`WARNING`、`INFO`、`CONFIG`、`FINE`、`FINER`和`FINEST`。本篇文章将深入探讨Java中的`Logger`封装,以及...

    APRESS--Logging-in-Java-with-the-JDK-1_4-Logging-API-and-Apache-log4j

    APRESS--Logging-in-Java-with-the-JDK-1_4-Logging-API-and-Apache-log4j

    Optimizing Java: Practical Techniques for Improving JVM Application Performance

    Pub Date: 2018 Learn how Java principles ...Explore JIT compilation and Java language performance techniques Learn performance aspects of the Java Collections API and get an overview of Java concurrency

    How is logging implemented in OSS?

    Method: In this paper, we carried out an empirical study to explore the logging practice in open source software projects so as to establish a basic understanding on how logging practice is applied ...

    Java LoggingAPI 使用方法

     Log4j中是通过log4j.properties这个配置文件控制日志的输出,java logging中是通过logging.properties文件完成类似的功能。  Logging.properties文件位于JDK安装路径的 jre/lib/目录下,直接上配置文件: ...

    java中logging的demo

    在Java编程语言中,日志(Logging)是一个关键的组件,用于记录应用程序的运行时信息。日志可以帮助开发者追踪程序的执行过程,诊断错误,优化性能,并为用户提供有关系统活动的详细信息。Java中的日志框架包括内置...

    《Programming in Java Second Edition》高清完整英文PDF版

    The second edition of Programming in Java confirms to Java Standard Edition 7, the latest release since Oracle took over Sun Microsystems. It is significant in the sense that the last update was six ...

    commons-logging.jar

    commons-logging-java1.1.jar, commons-logging-optional.jar, commons-logging-osgi-1.0.jar, commons-logging-osgi.jar, commons-logging-REDUCED.jar, commons-logging-tests.jar, commons-logging_1.0.3.jar, ...

    commons-logging-1.2

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

    commons-logging-1.2_commonslogging_

    Apache Commons Logging(简称Commons Logging)是Apache软件基金会开发的一个开源项目,它提供了一个轻量级的日志API,旨在为Java应用程序提供一个简单的接口来记录日志信息。这个接口能够适配多种流行的日志实现,...

    java 开发工具:commons-logging.jar(spring必备包)

    java 开发工具:commons-logging.jar(spring必备包)

    java.lang.NoClassDefFoundError: org/jboss/logging/

    Java编程中的`java.lang.NoClassDefFoundError: org/jboss/logging/`是一个常见的运行时错误,通常发生在尝试执行一个类时,JVM无法找到在编译时已经存在的类定义。这个错误并不意味着类在编译期间不存在,而是表明...

    commons-logging-1.1.1.jar和java-unrar-0.3.jar

    总之,"java-unrar-0.3.jar"和"commons-logging-1.1.1.jar"为Java开发者提供了处理RAR文件的强大工具,使得在Java环境中解压RAR文件变得简单易行,同时通过Commons Logging提供了灵活的日志记录机制。在项目中正确...

    Common Logging的jar包.zip

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

    the-complete-guide-to-logging.original

    java logging in production. Introduction...............................................................................................................Page 2 Chapter 1...................................

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

    标签:jboss、logging、jar包、java、API文档、中文版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译,请...

    java写日志的jar包——commons-logging-1.0.4.jar

    commons-logging-1.0.4.jar可以引入: org.apache.commons.logging.Log,org.apache.commons.logging.LogFactory等,用于写日志。 免费送,只要1积分

Global site tag (gtag.js) - Google Analytics