码迷,mamicode.com
首页 > 其他好文 > 详细

Configuring log4j

时间:2014-10-12 17:59:48      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   ar   for   sp   div   

Configuring log4j typically involes assigning level objects, defining appender objects, and specifying Layout objects. 

  • naming and placing the configuation file

By default, the LogManager class will look for a file named log4j.properties or log4j.xml in the classpath used for loading the log4j classes.

If you decide to name your configuation file differently, you are free to do that. However you have to let the log4j framework know by supplying  a command line argument as follows:

-Dlog4j.cofinguation="file_name".

 

bubuko.com,布布扣

# define the root logger with two appenders writing to console and file
log4j.rootLogger = DEBUG, CONSOLE, FILE
#define your own logger named com.foo
#and assign level and appender to your own logger
log4j.logger.com.foo=DEBUG,FILE
#define the appender named FILE
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=${user.home}/log.out
#define the appender named CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.conversionPattern=%m%n

notable points about Configuration

  • the configuation file is case-sensive
  • a few of appenders can be only configured through an XMl file
  • some advanced controls, such as Filter and ObjectRender, can be configured only via an XML file.

Configuring log4j

标签:style   blog   http   color   io   ar   for   sp   div   

原文地址:http://www.cnblogs.com/woodynd/p/4020616.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!