Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting log4j to write to multiple log files

 
Dave Trower
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a Tomcat application that uses log4j.
I want to create several logs to several differant files.
I tried creating several loggers with differant names and these loggers used differant conifiguration property files but when I change the settings for one logger it changes it for all the logggers.
 
Guy Allard
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you want to create different log files for code in different Java packages, this is fairly easy. You only need one log4j configuration file.

Here is an example that should get you started. Watch what is commented out, this is a cut and paste of current config.



Guy
[ November 17, 2007: Message edited by: Guy Allard ]
 
Mohan Karthick
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this but not working I simply run a java application in a loop which is calling x.java and y.java, want to create log for x.log and y.log calling both the classes from XY.java main method, logs are mixing up I am using DOMConfigurator static block.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic