Dear ladies and sirs.
We are using log4net for our server side logging. The problem we are facing is with the FileAppender. Here is our log4net section in the app.config file:
<log4net xsi:noNamespaceSchemaLocation="http://csharptest.net/downloads/schema/log4net.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<appender name="MainAppender" type="log4net.Appender.FileAppender">
<lockingMode type="log4net.Appender.FileAppender+MinimalLock" />
<file value="${TMP}\Shunra.Infra.Test.Host.log" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="ERROR" />
<appender-ref ref="MainAppender" />
</root>
</log4net>
The thing is that when multiple threads write to the log file, log4net sometimes fails to acquire the lock to the file, because another thread is logging at this same moment. The problem manifests itself in a first chance IOException handled by log4net internally.
I am not sure that we are using log4net correctly in this case and would like to get an advice on how to improve its configuration.
Thanks.