My project will have some number of class "foo" each running in a seperate thread. (foo implements runnable).
as each instance of foo runs, it may want to log a message to a file. I want the out put of each instances log request to go to a seperate file.
Searching for google; I have found several people asking how to solve this problem using log4j, I have not found an aswer yet. someone mentioned extending FileAppender, but I don't comprehend what to do.
Not sure what to suggest here.... From the documentation I read, I see that there are ways to add different Appenders so you can write to different files (using FileAppender class). But I haven't seen a way to add different Appenders dynamically, which seems to be what you want to do.
If I am not mistaken, and if I can re-phrase your question - You want to add a different FileAppender to different threads? Is that right?
I did some testing with the addAppender("fileName") message but I wasn't able to create a log file. I ended up using the log4J.xml file method discussed in the other posts here.
I will try to give it one more try and update if I find anything new. [Sorry, not a solution to your problem, but just thinking out loud.]
Extend one of the FileAppender classes (RolloginFileAppender or DailyRol...). Add an attribute MyLogType - much like the Level. Implement logic based on MyLogType values, assuming you are familiar with the logic of Level. On your foo class, add the same attribute and set its value.
Just follow the same concept as what Log4J does with Level. Any other thoughts are most welcome.