0

Possible Duplicate:
Creating multiple log files of different content with log4j

I am working with jboss server. Is it possible to use two logs using log4j? i am successfully able to work with one , for writing file and writing in database should be different. Can we able to create two instance of log in class one to write in file and another in jdbcadapter

Community
  • 1
  • 1
Mallika
  • 47
  • 4
  • Check [Creating multiple log files of different content with log4j](http://stackoverflow.com/q/728295/1048330) and – tenorsax Apr 10 '12 at 04:24
  • Can we able to create two instance of log in class one to write in file and another in jdbcadapter , Logger log = Logger.getLogger(this.getClass()); is one to write log in console and another one in like Logger log1 = Logger.getLogger(this.getClass()); write in database within one class – Mallika Apr 10 '12 at 06:30

2 Answers2

0

Yes. Create multiple Appenders and assign messages of a given <category> to one or the other using <appender-ref>.

Chris Nava
  • 6,614
  • 3
  • 25
  • 31
0

Thats the whole point of log4j. Multiple appenders can be attached top loggers

log4j.categry.com.mypackage=INFO, file, database

log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.##OtherProperies##=##OtherValues##

log4j.appender.database=org.apache.log4j.JDBCAppender
log4j.appender.databse.##OtherProperies##=##OtherValues##

or can use DatabaseAppender too

manocha_ak
  • 904
  • 7
  • 19