Reputation: 3428
So I am using Common.Logging.Log4Net for logging purposes, but since the code is multithreaded, often messages get mixed up, eg:
message from thread 1 message from thread 2 message from thread 1 message from thread 1 message from thread 2
In order to avoid this, we are trying to get all messages together and we print them all when the execution finishes. For that we basically have a list of Action delegates and each contains the log line, eg:
Log.DebugFormat("Handling...");
But this unfortunately does not solve any issue, because when we write back to the log, messages still get mixed, since all we do is a foreach on the list and execute the delegates. So is there any way to get all the messages written at once?
Upvotes: 2
Views: 513
Reputation: 844
Sounds like you're looking for some sort of transaction logging. By nature, application logging is sequential.
A couple of options I can think of off-hand:
Upvotes: 2