没有合适的资源?快使用搜索试试~ 我知道了~
log4j2+slf4j+spring4+mybatis的整合使用
需积分: 6 7 下载量 30 浏览量
2019-05-01
01:39:22
上传
评论
收藏 1.31MB PDF 举报
温馨提示
试读
271页
NULL 博文链接:https://pengjj2.iteye.com/blog/2398043
资源推荐
资源详情
资源评论
......................................................................................................................................
Apache Log4j 2
v. 2.9.1
User's Guide
......................................................................................................................................
The Apache Software Foundation 2017-09-17
T a b l e o f C o n t e n t s
i
© 2 0 1 7 , T h e A p a c h e S o f t w a r e F o u n d a t i o n • A L L R I G H T S R E S E R V E D .
Table of Contents
.......................................................................................................................................
1.
Table of Contents ........................................................... i
2.
Introduction ................................................................. 1
3.
Architecture ................................................................. 3
4.
Log4j 1.x Migration ........................................................ 10
5.
API .......................................................................... 17
6.
Configuration ............................................................... 20
7.
Web Applications and JSPs .............................................. 56
8.
Plugins ...................................................................... 65
9.
Lookups .................................................................... 69
10.
Appenders .................................................................. 77
11.
Layouts .................................................................... 163
12.
Filters ...................................................................... 196
13.
Async Loggers ............................................................ 211
14.
Garbage-free Logging .................................................... 225
15.
JMX ........................................................................ 234
16.
Logging Separation ....................................................... 241
17.
Extending Log4j .......................................................... 243
18.
Programmatic Log4j Configuration ...................................... 254
19.
Custom Log Levels ....................................................... 262
T a b l e o f C o n t e n t s
ii
© 2 0 1 7 , T h e A p a c h e S o f t w a r e F o u n d a t i o n • A L L R I G H T S R E S E R V E D .
1 I n t r o d u c t i o n
1
© 2 0 1 7 , T h e A p a c h e S o f t w a r e F o u n d a t i o n • A L L R I G H T S R E S E R V E D .
1 Introduction
.......................................................................................................................................
1.1 Welcome to Log4j 2!
1.1.1 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.
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":
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.
1.1.2 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.
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.
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.
剩余270页未读,继续阅读
资源评论
weixin_38669628
- 粉丝: 383
- 资源: 6万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功