views:

61

answers:

3

Here's the deal: Currently, I've got my own logging system, where the log is essentially a queue, with a separate thread listening to that queue and doing all of the actual write operations. The system processes a TON of log messages, files can easily exceed 10 MB sizes in minutes, so doing the actual logging in the calling thread is not feasible.

I can't find resources online that show how threading would work in log4net, if log4net supports this kind of message passing architecture already, or other similar features to work in a threaded environment. Are there any pre-existing features that would help me?

Is this possible without creating a log4net wrapper?

+1  A: 

You may want to rethink the threading approach if your log data depends on being in a specific order -- threading may interfere with that and end up posting log entries out of sequence.

You could try using MSMQ (or some other queue technology) to quickly post the log messages off to some other process which will then do the physical writes to storage. This will guarantee that messages appear in the same order they were sent.

Dr Herbie
MSMQ is very heavyweight, especially for this. An in-memory queue is enough.
Steven Sudit
An in-memory queue is how the current implementation of my logger does it. I suppose I'll have to extend it to log4net and wrap it. Or create my own appender.
Stefan Valianu
Since he's using a queue, the order of logging will match the order of insertion, so there won't be a problem.
Steven Sudit
+1  A: 

It's not a bad idea. The trick is to queue up the entries and process them in a single queue. Take a look at http://www.drdobbs.com/visualstudio/225700095 for a good example.

Steven Sudit
+1  A: 

You can always look at the source code for log4net to bottom out these sorts of questions. It is open source.

chibacity
It's a bit harder to dig down in a huge class library. However, searching for new Thread returns nothing useful, searching for ThreadPool shows an appender that "sort of" does something useful for my purposes, but is nowhere near the mark.Guess I have to make my own appender. :(
Stefan Valianu