• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Getting log4j to write to multiple log files

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic