This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

log4j: How to write to multiple log files?

 
lydia edward
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using log4j for logging events in my application and I want to log various actions from various classes into two different log files.
Only the classes from 3 or 4 packages must log to "aaa.log" file and all other classes must log to "bbb.log" file.
Can someone please help me out in this and let me know how to go about this?


I tried the following log4j.properties file...but this is creating only the Logs.log file file. Please help!


log4j.rootLogger=DEBUG

log4j.logger.abc.xyz.xxx.controller=DEBUG, default
log4j.appender.AdminLogAppender=org.apache.log4j.FileAppender
log4j.appender.AdminLogAppender.File=../logs/AdminLogs.log
log4j.appender.AdminLogAppender.layout=org.apache.log4j.PatternLayout

log4j.logger.abc.xyz.yyy.controller=DEBUG, default
log4j.appender.AdminLogAppender=org.apache.log4j.FileAppender
log4j.appender.AdminLogAppender.File=../logs/AdminLogs.log
log4j.appender.AdminLogAppender.layout=org.apache.log4j.PatternLayout

log4j.logger.abc.xyz=DEBUG, default
log4j.appender.default=org.apache.log4j.FileAppender
log4j.appender.default.File=../logs/Logs.log
log4j.appender.default.layout=org.apache.log4j.PatternLayout

log4j.appender.default.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.AdminLogAppender.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

Regards
Lydia
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic