Log4j学习笔记
来源:互联网 发布:java 循环jsonarray 编辑:程序博客网 时间:2024/06/11 12:36
1.Log4j has three main components:
loggers, appenders and layouts
2.Some of the basic methods in the Logger class are listed below.
package org.apache.log4j; public class Logger { // Creation & retrieval methods: public static Logger getRootLogger(); public static Logger getLogger(String name); // printing methods: public void trace(Object message); public void debug(Object message); public void info(Object message); public void warn(Object message); public void error(Object message); public void fatal(Object message); // generic printing method: public void log(Level l, Object message);}
Loggers may be assigned levels. The set of possible levels, that is:
TRACE,
DEBUG,
INFO,
WARN,
ERROR and
FATAL
A logging request is said to be enabled if its level is higher than or equal to the level of its logger.
3.
Appenders and Layouts
The ability to selectively enable or disable logging requests based on their logger is only part of the picture. Log4j allows logging requests to print to multiple destinations. In log4j speak, an output destination is called an appender. Currently, appenders exist for the console, files, GUI components, remote socketservers, JMS, NT Event Loggers, and remote UNIX Syslog daemons. It is also possible to log asynchronously.
More than one appender can be attached to a logger.
The addAppender method adds an appender to a given logger. Each enabled logging request for a given logger will be forwarded to all the appenders in that logger as well as the appenders higher in the hierarchy. In other words, appenders are inherited additively from the logger hierarchy. For example, if a console appender is added to the root logger, then all enabled logging requests will at least print on the console.If in addition a file appender is added to a logger, say C, then enabled logging requests for C and C's children will print on a file and on the console. It is possible to override this default behavior so that appender accumulation is no longer additive by setting the additivity flag to false.
The rules governing appender additivity are summarized below.
- Log4J学习笔记
- Log4J学习笔记
- Log4j 学习笔记
- Log4j 学习笔记
- Log4j 学习笔记
- [转贴] Log4j 学习笔记
- log4j 学习笔记
- Log4j学习笔记
- Log4J学习笔记
- log4j学习笔记(转载)
- lOG4J学习笔记
- Log4j 学习笔记
- Log4J学习笔记(一)
- Log4j 学习笔记
- log4j学习笔记(1)
- Log4j 学习笔记
- log4j学习笔记
- Log4j 学习笔记
- 什么方法将txt转换pdf最有效
- 既然有了elasticsearch为什么还要用hadoop和spark呢?good question
- linux sort 命令
- web.xml中的contextConfigLocation在spring中的作用
- R语言实例-数据过滤
- Log4j学习笔记
- ActiveMQ学习总结(5)——Java消息服务JMS详解
- boost camp 分区失败处理方法
- ThinkPad T440 Win10系统长时间睡眠之后无法唤醒的问题
- 关于DES加密,适用Andriod、iOS与JAVA后台
- python re 里面match 和search的区别
- 【哈希】【动态规划】[NOIP模拟赛]仔细的检查
- iOS中显示自带地图(高德地图)的大头针
- 最快遍历完图中重要节点 树的直径 Codeforces 328 (Div. 2) D. Super M