• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

log4j: How to write to multiple log files?

 
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
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!