logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark A. DeMichele" <d...@intellipro.com>
Subject Using log4Net to log multiple files by different users/tasks
Date Sun, 05 Oct 2008 13:43:05 GMT
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
So far, I believe I must create an individual Appender for each task.
Something like this.
PatternLayout layout = new PatternLayout("%date{dd-MM-yyyy HH:mm:ss,fff}
%5level [%2thread] %message (%logger{1}:%line)%n");
FileAppender appender = new FileAppender();
appender.Layout = layout;
appender.File = "d:\\logs\\" + TaskID.ToString()+ ".txt";
appender.AppendToFile = true;
appender.Name = "File";
appender.Threshold = log4net.Core.Level.All;

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.


View raw message