Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Log4j Property

 
Syed Saifuddin
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I am introducing log4j in my application and succeeded to do so. But now I want to saperate the log in different file according to their LEVEL i.e.

debug log should go in debug.log file and
warn log should go in warn.log file and
similarly other error and info and fatal.

Please help me in the regard.

Thankyou
Syed Saifuddin
Java Developer
 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create 3 file appenders in your log4j config file.

Example:
debugAppender
warnAppender
errorAppender

Then you can set the appender you want to use. Example:
private static final Logger LOG = Logger.getLogger("warnAppender");
LOG.warn("An exception was thrown");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic