In your code the File property gets set when the Appender is created. Here's an example showing how to set the File property based on each logging event:
http://svn.apache.org/viewvc/logging/log4net/trunk/examples/net/1.0/Appenders/SampleAppendersApp/cs/src/Appender/PatternFileAppender.cs?view=markup That example code is probably slow. log4j and nlog have file appenders that keep the most recent files open so you don't have to pay the open/close penalty. You could probably extend the FileAppender and override a method or two to do what you want. ----- Original Message ---- From: Mark A. DeMichele <[EMAIL PROTECTED]> To: [email protected] Sent: Sunday, October 5, 2008 9:43:05 AM Subject: Using log4Net to log multiple files by different users/tasks I have an asp.net site in which different users run different tasks. Each individual task is managed by a TaskManager that I'm writing. While each task is running it has the opportunity to log to it's own log file. I'm trying to use Log4Net to do this, but so far I've been unable to figure out how exactly to accomplish this. Any advice would be appreciated. So far, I believe I must create an individual Appender for each task. Something like this. PatternLayoutlayout = newPatternLayout("%date{dd-MM-yyyy HH:mm:ss,fff} %5level [%2thread] %message (%logger{1}:%line)%n"); FileAppenderappender = newFileAppender(); appender.Layout = layout; appender.File = "d:\\logs\\"+ TaskID.ToString()+ ".txt"; appender.AppendToFile = true; appender.Name = "File"; appender.Threshold = log4net.Core.Level.All; appender.ActivateOptions(); And I know that eventaully, I'll want to code to call something like ILog _Log = LogManager.GetLogger(TaskID.ToString()); But I can't figure out how to make that logger unique and how to associate that single appender to it and not to have that single appender interfere with other users and tasks. I'm starting to think that this is not possible with Log4Net. Maybe Log4Net is made more to have global loggers and not many individual task related ones. I'd appreciate any help anyone can give me. Thanks.
