CSDN博客

img smilingleo

Log4J学习笔记

发表于2004/9/28 13:41:00  835人阅读

分类: 笔记心得

Three Basic Concept:
Category:
you instantiate a category instance, you can call its various logging methods(such as debug, info, warn, error, fatal) to send your message to log.
Appender:
Different destinations the message is appended. for example, file, console, jdbc, etc.
Layout: In which format you want your logging message will be appended. SimpleLayout, HTMLLayout, PatternLayout

A file named log4j.properties should be created and placed in same classpath with your application which invokes the log API.

Patterns associated with MDC(mapped diagnositic context):
org.apache.log4j.MDC
 -static void put(String key, Object o)
 - MDC.put(“server”,”jaguar”);
 - MDC.put(“test”,”myContext”);
In PatternLayout=%d %X{server} %X{test}  //Be careful, X is case sensitive.
 -static void remove(String key)

阅读全文
0 0

相关文章推荐

  • log4j的学习笔记
    cherry23415 2011-05-13 22:41 0
  • log4J学习笔记
    liona841875956 2012-05-09 20:44 0
  • log4j详细的学习笔记.
    chaohuabai 2010-04-05 14:31 2
  • log4j学习笔记
    SeeBefore 2008-03-26 12:35 12
  • Log4j学习笔记
    qq_35508033 2017-06-04 19:18 226
  • log4j学习笔记.
    zjd950131 2007-04-16 06:36 622
  • Apache Log4j 学习笔记
    tomato8524 2011-12-16 11:08 547
  • Log4j学习笔记
    wutongchen 2012-09-01 13:30 0
img
取 消
img