aspose file tools*
The moose likes Other Open Source Projects and the fly likes Getting log4j to write to multiple log files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Getting log4j to write to multiple log files" Watch "Getting log4j to write to multiple log files" New topic
Author

Getting log4j to write to multiple log files

Dave Trower
Ranch Hand

Joined: Feb 12, 2003
Posts: 86
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

Joined: Nov 24, 2000
Posts: 776
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

Joined: Apr 11, 2005
Posts: 199
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Getting log4j to write to multiple log files