Welcome to Log4j 2!

Introduction

Almost every large application includes its own logging or tracing API. In conformance with this rule, the E.U. SEMPER project decided to write its own tracing API. This was in early 1996. After countless enhancements, several incarnations and much work that API has evolved to become log4j, a popular logging package for Java. The package is distributed under the Apache Software License, a fully-fledged open source license certified by the open source initiative. The latest log4j version, including full-source code, class files and documentation can be found at http://logging.apache.org/log4j/2.x/index.html.(几乎每一个大型应用程序都包含自己的日志记录或跟踪API.为了顺应这个规则,E.U.  SEMPER项目决定写它自己的跟踪API。这是在1996年初。经过无数的增强, 好几个变身和大量的工作,这个API已经发展成为 log4j,一个流行的java日志记录包。这个包分发在 Apache软件许可协议下。最新的log4j的版本,包括完整的源代码,类文件和 文件,它们可以在http://logging.apache.org/log4j/2.x/index.html网站中找到。)

Inserting log statements into code is a low-tech method for debugging it. It may also be the only way because debuggers are not always available or applicable. This is usually the case for multithreaded applications and distributed applications at large.(对于调试代码,将日志语句插入代码是一种低技术方法 。它也可能是唯一的方法,因为使用调试器进行调试不总是有效的和合适的。一般来说,这种情况通常发生在多线程应用程序和分布式应用程序。)

Experience indicates that logging was an important component of the development cycle. It offers several advantages. It provides precise context about a run of the application. Once inserted into the code, the generation of logging output requires no human intervention. Moreover, log output can be saved in persistent medium to be studied at a later time. In addition to its use in the development cycle, a sufficiently rich logging package can also be viewed as an auditing tool.(经验表明,测试是开发周期里的一个重要组成部分。它提供了几个优点。它提供了有关应用程序运行的精确上下文。一旦将日志插入到代码中,日志输出的生成就不需要人工干预。此外,日志输出可以保存在持久性介质中进行研究,在稍后的时间。除了其在开发周期中的使用,一个足够丰富的日志包也可以被看作是一个审计工具。)

As Brian W. Kernighan and Rob Pike put it in their truly excellent book "The Practice of Programming":(Brian W. Kernighan和Rob Pike把它放在他们真正的优秀书“编程实践”中:)

As personal choice, we tend not to use debuggers beyond getting a stack trace or the value of a variable or two. One reason is that it is easy to get lost in details of complicated data structures and control flow; we find stepping through a program less productive than thinking harder and adding output statements and self-checking code at critical places. Clicking over statements takes longer than scanning the output of judiciously-placed displays. It takes less time to decide where to put print statements than to single-step to the critical section of code, even assuming we know where that is. More important, debugging statements stay with the program; debugging sessions are transient.(作为个人的选择,我们倾向于不使用功能强于“能够得到堆栈跟踪或变量的值”的调试器。原因之一是 复杂数据结构的细节和控制流容易丢失 ;我们发现一步一步调试,比 努力思考,增加输出语句并在关键的地方自我检查代码更加低效。打断点进行语句调试需要更长的时间来插件调试器输出的堆栈信息。思考需要在哪里打印日志,比单步调试到关键部分的代码需要更少的时间。更重要的是,调试语句和程序是保持一致; 调试信息会随着程序的运行而消失。)

Logging does have its drawbacks. It can slow down an application. If too verbose, it can cause scrolling blindness. To alleviate these concerns, log4j is designed to be reliable, fast and extensible. Since logging is rarely the main focus of an application, the log4j API strives to be simple to understand and to use.(日志记录有其缺点。它会使应用变慢。如果太冗长,它可以导致滚动失明。为了缓解这些担忧,log4j的设计是可靠的,快速的而且可扩展。由于日志几乎不会是应用程序的主要焦点, log4j API力求简单易懂,使用。)

Log4j 2

Log4j 1.x has been widely adopted and used in many applications. However, through the years development on it has slowed down. It has become more difficult to maintain due to its need to be compliant with very old versions of Java and became End of Life in August 2015. Its alternative, SLF4J/Logback made many needed improvements to the framework. So why bother with Log4j 2? Here are a few of the reasons.(Log4j 1。x已被广泛用于许多应用程序。然而, 经过多年的发展,它已经放缓。它变得更加 很难维护,因为它需要遵守非常旧的 java版本 并且在2015年8月它的生命终止。 他的替代品,slf4j / logback提供了许多这个框架需要改进的东西。为什么使用log4j 2?这里有几个原因。)

  1. Log4j 2 is designed to be usable as an audit logging framework. Both Log4j 1.x and Logback will lose events while reconfiguring. Log4j 2 will not. In Logback, exceptions in Appenders are never visible to the application. In Log4j 2 Appenders can be configured to allow the exception to percolate to the application.(Log4j 2的设计是作为一种审计日志框架使用。log4j 1.x和logback在重新配置时会失去事件 。Log4j 2不会。在 Logback,应用程序看不到Appenders中的异常。在 Log4j 2 appender可以被配置为允许异常渗入应用。)
  2. Log4j 2 contains next-generation Asynchronous Loggers based on the LMAX Disruptor library. In multi-threaded scenarios Asynchronous Loggers have 10 times higher throughput and orders of magnitude lower latency than Log4j 1.x and Logback.(log4j 2包含下一代基于LMAX Disruptor library的 异步记录器 。 在多线程情况下异步记录器有 比log4j 1.x和logback 高 10倍的吞吐量和更低的延迟。)
  3. Log4j 2 is garbage free for stand-alone applications, and low garbage for web applications during steady state logging. This reduces pressure on the garbage collector and can give better response time performance.(Log4j 2在stand-alone(独立可执行应用程序)应用程序中不会产生垃圾,并且在web应用程序记录日志的时候会产生较低的垃圾。这减少了垃圾收集器的压力,并且提供更快的响应时间)
  4. Log4j 2 uses a Plugin system that makes it extremely easy to extend the framework by adding new Appenders, Filters, Layouts, Lookups, and Pattern Converters without requiring any changes to Log4j.(Log4j 2使用插件系统,这使得它及其容易通过添加新的 AppendersFiltersLayoutsLookups, 和Pattern Converters 进行扩展,而不需要修改Log4j的任何代码)
  5. Due to the Plugin system configuration is simpler. Entries in the configuration do not require a class name to be specified.(由于插件系统的配置更加简单。在配置中的实体不再需要为其指定类名。)
  6. Support for custom log levels. Custom log levels can be defined in code or in configuration.(支持自定义日志级别。可以通过代码,或者在配置文件中自定义日志级别。)
  7. Support for lambda expressions. Client code running on Java 8 can use lambda expressions to lazily construct a log message only if the requested log level is enabled. Explicit level checks are not needed, resulting in cleaner code.(支持 lambda expressions。运行在Java8上的代码可以使用 lambda expressions  来更便捷的构造一个日志消息,只有当这个日志级别是启用的时候才有效。不再需要通过代码检查该级别的日志是否启用,使得代码更加简洁。)
  8. Support for Message objects. Messages allow support for interesting and complex constructs to be passed through the logging system and be efficiently manipulated. Users are free to create their own Message types and write custom Layouts, Filters and Lookups to manipulate them.(支持消息对象。支持有趣的和复杂结构的消息通过日志记录系统传递,并被有效地操纵。用户可以自由的创建自己的消息类型和编写自定义LayoutsFilters and Lookups 来操作消息。)
  9. Log4j 1.x supports Filters on Appenders. Logback added TurboFilters to allow filtering of events before they are processed by a Logger. Log4j 2 supports Filters that can be configured to process events before they are handled by a Logger, as they are processed by a Logger or on an Appender.(Log4j 1.X支持在Appenders中使用Filters 。Logback添加turbofilters,它可以在事件被日志记录器处理之前过滤事件。Log4j 2支持这样的过滤器,它们可以被配置为在事件被日志记录器处理之间先过滤事件,就好像它们是被日志记录器或Appender处理一样。)
  10. Many Logback Appenders do not accept a Layout and will only send data in a fixed format. Most Log4j 2 Appenders accept a Layout, allowing the data to be transported in any format desired.(许多Logback Appenders不接受Layout,只会发送一个固定的格式数据。大多数的Log4j 2的Appenders  会接受一个Layout,允许数据以你想要的任何格式传输数据 。)
  11. Layouts in Log4j 1.x and Logback return a String. This resulted in the problems discussed at Logback Encoders. Log4j 2 takes the simpler approach that Layouts always return a byte array. This has the advantage that it means they can be used in virtually any Appender, not just the ones that write to an OutputStream.(log4j 1.x中的Layouts 和Logback  会返回一个字符串。这导致在 Logback Encoders中讨论的问题。Log4j 2以更简单的方法---- Layouts始终返回一个字节数组。这样做的好处是,他们几乎可以在任何Appender 中使用,不仅仅是写入到一个输出流中。)
  12. The Syslog Appender supports both TCP and UDP as well as support for the BSD syslog and the RFC 5424 formats.(Syslog Appender支持TCP和UDP以及BSD syslog和RFC 5424格式 )
  13. Log4j 2 takes advantage of Java 5 concurrency support and performs locking at the lowest level possible. Log4j 1.x has known deadlock issues. Many of these are fixed in Logback but many Logback classes still require synchronization at a fairly high level.(Log4j 2利用java 5并发支持和在可能的最低水平上执行锁定。Log4j 1.x有已知的死锁问题。这些问题中的许多都会出现在Logback中,但Logback  中的许多类还需要在在一个相当高的水平上保持同步。)
  14. It is an Apache Software Foundation project following the community and support model used by all ASF projects. If you want to contribute or gain the right to commit changes just follow the path outlined at Contributing.(这是一个Apache软件基金会的项目。如果你想贡献或者获得改变的权利,那就按照Contributing去做。)

1.Introduction 介绍的更多相关文章

  1. 一: Introduction(介绍)

    Welcome to SQLBackupRestore.com, your online resource for SQL Server backup and recovery issues.  Th ...

  2. Security » Authorization » 介绍

    Introduction¶ 介绍 77 of 87 people found this helpful Authorization refers to the process that determi ...

  3. rabbitmq 的心跳机制&应用

    官方文档说: If a consumer dies (its channel is closed, connection is closed, or TCP connection is lost) w ...

  4. [原创博文] 用Python做统计分析 (Scipy.stats的文档)

    [转自] 用Python做统计分析 (Scipy.stats的文档) 对scipy.stats的详细介绍: 这个文档说了以下内容,对python如何做统计分析感兴趣的人可以看看,毕竟Python的库也 ...

  5. Lua 架构 The Lua Architecture

    转载自:http://magicpanda.net/2010/10/lua%E6%9E%B6%E6%9E%84%E6%96%87%E6%A1%A3/ Lua架构文档(翻译) 十 102010 前段时间 ...

  6. 【转】Application.mk 文件语法规范

    原文网址:http://blog.sina.com.cn/s/blog_4c451e0e0100s6q4.html Application.mk file syntax specification A ...

  7. .htaccess文件的详解以及404页面的设置

    打开记事本,写入以下代码: ErrorDocument 404 /404.html保存成.htaccess文件上传到网站的根目录. /404.html是目录名和文件名,可以改成自己的名字.QUOTE: ...

  8. SharePoint 2010中使用SPListItemCollectionPosition更快的结果

    转:http://www.16kan.com/article/detail/318657.html Introduction介绍 In this article we will explore the ...

  9. 任何时候都适用的20个C++技巧

    这些小技巧之所以特别,是因为这些信息通常吧不能在C++书籍或者网站上找到.比如说,成员指针,即使对于高级程序员也是比较棘手,和易于产生bugs的,是应该尽量避免的问题之一. <翻 by凌云健笔& ...

随机推荐

  1. SpringAop详解

    近几天学习了一下SpringAop在网上找了一些资料,此链接为原文链接http://www.cnblogs.com/xrq730/p/4919025.html AOP AOP(Aspect Orien ...

  2. 定制自己的vue模版

    前言 使用vue这个框架已经陆陆续续做了好几个项目了,不知不觉也已经在公司呆了4个月,转正了.时间如水...(省略一万字)./咳-不瞎扯了,公司是直接用的官方脚手架生成项目,官方模版没有vuex,ax ...

  3. (原)怎样解决python dataframe loc,iloc循环处理速度很慢的问题

    怎样解决python dataframe loc,iloc循环处理速度很慢的问题 1.问题说明 最近用DataFrame做大数据 处理,发现处理速度特别慢,追究原因,发现是循环处理时,loc,iloc ...

  4. web前端面试官挖的那些坑(js)

    题目1: function Foo() { getName = function () { alert (1); }; return this; } Foo.getName = function () ...

  5. 虚拟机中ubuntu-16.04 Linux系统下配置mysql数据库,并在windows下使用navicat远程连接

    Linux系统下mysql数据库安装配置步骤: 1.在服务器上安装mysql:sudo apt-get install mysql-server sudo apt-get install mysql- ...

  6. java web Servlet 学习笔记 -3 会话管理技术

     Cookie和HttpSession 什么是会话: 用户开一个浏览器,点击多个超链接,访问服务器多个web资源,然后关闭浏览器,整个过程称之为一个会话. 每个用户在使用浏览器与服务器进行会话的过 ...

  7. Linux文件类型介绍

    文件类型介绍: Linux系统不同于Windows系统,两者文件类型和文件扩展名也有很大的差异.Linux中的文件类型和Linux文件的文件扩展名所代表的意义和Windows系统完全不同.用户一般通过 ...

  8. 【网络爬虫入门05】分布式文件存储数据库MongoDB的基本操作与爬虫应用

    [网络爬虫入门05]分布式文件存储数据库MongoDB的基本操作与爬虫应用 广东职业技术学院  欧浩源 1.引言 网络爬虫往往需要将大量的数据存储到数据库中,常用的有MySQL.MongoDB和Red ...

  9. c++中vector的pair与make_pair的使用,双关键字排序

    #include <vector> #include <iostream> #include <algorithm> using namespace std; bo ...

  10. mysql分表场景分析与简单分表操作

    为什么要分表 首先要知道什么情况下,才需要分表个人觉得单表记录条数达到百万到千万级别时就要使用分表了,分表的目的就在于此,减小数据库的负担,缩短查询时间. 表分割有两种方式: 1水平分割:根据一列或多 ...