This problem arises often. Some want to separate the log files of servlets by 
different criterias (sessionID, userID, etc.), others (like me) have a 
scheduler which fires different tasks on different customers where the log 
output should be separated.

I thought one could enhance the file appender itself by suppliying it with a 
kind of FileNameBuilder-Class. So this enhancement would apply to all 
descendants of file appender (Rolling, DailyRolling, etc.). The FileNameBuilder 
could build the filename by using values of MDC or any other criterias, and the 
file appender can then hold a bundle of different targets, like described below 
by Curt Arnold. In my opinion this would be more flexible than a hard coded 
pattern which just relys on the thread name.

Any thoughts?

Heri

> -----Original Message-----
> From: Curt Arnold [mailto:[EMAIL PROTECTED]
> Sent: Friday, September 15, 2006 6:19 PM
> To: Log4J Users List
> Subject: [SPAM (Bayesain Analysis)] - Re: Separate log files 
> per thread.
> - Bayesian Filter detected spam
> 
> 
> 
> On Sep 14, 2006, at 4:11 PM, James Stauffer wrote:
> 
> > 4. Write your own appender that potentially changes the logfile name
> > per logging event.  I do a smiliar thing with an appender.
> > http://stauffer.james.googlepages.com/DateFormatFileAppender.java
> >
> 
> 
> 5. Discuss the requirements for such an appender on the mailing list  
> and see if a consensus could be formed.  If so, a sandbox project  
> could be started to develop the appender and when functional 
> it might  
> get added into log4j itself.  You also might check if log4net might  
> already have something similar and if so, we might port it back from  
> there.
> 
> I thought about it a little.  It was thinking that you might specify  
> a java.text.MessageFormat pattern for file name using Thread.getName 
> () (or Thread.toString() if name was blank), the maximum number of  
> open files, plus the WriterAppender properties.  The appender would  
> keep a hashmap of Writers keyed by the generated file name and would  
> maintain it so it closed the stalest Writer if the open file count  
> would have been exceeded.
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to