We use log4net for server-side logging. The problem we are facing is related to 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 fact is that when several threads write to the log file, log4net sometimes cannot get a lock for the file, because another thread is registered at the same moment. The problem manifests itself in the first case when an IOException is handled by log4net internally.
I'm not sure that we are using log4net correctly in this case and would like some advice on how to improve its configuration.
Thanks.
source share