cjbhaines / Log4Net.Async

Asynchronous Log4Net appenders and forwarder
http://www.nuget.org/packages/Log4Net.Async/
MIT License
121 stars 37 forks source link

ParallelForwardingAppender do not mix Task and Threads #39

Open xmedeko opened 6 years ago

xmedeko commented 6 years ago

Current implementation of ParallelForwardingAppender is wrong, since it block a thread form the default ThreadPool. The C# Tasks and Threads should not be mixed together. {{BlockingCollection}} is based on a thread synchronization (lock), so do not use it for the Task running on a ThreadPool.

The Task based producer - consumer is a bit more complicated, e.g. see Stephen Clearys's or .NET doc). Anyway, do not use tasks, since the ForwardLoggingEvent is not Task-based. (E.g. some appender sending logs by network may have long log times.) Just start a new plain thread.

See also #37