I knew that the log4net documentation indicates that recording caller location information can be very slow and should not be used unless it affects software performance.
And until the update for Windows 10 Fall Creator developers was like that. Here is a small project example.
app.config
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" /> </configSections> <log4net> <appender name="DefaultAppender" type="log4net.Appender.RollingFileAppender"> <file value="logging.log" /> <encoding value="utf-8" /> <appendToFile value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%d | %-5p | %t | %C.%M:%L | %m%n" /> </layout> </appender> <root> <level value="All" /> <appender-ref ref="DefaultAppender" /> </root> </log4net> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> </configuration>
Program.cs
using System; using System.Diagnostics; using log4net; namespace Log4Net.CSharp { class Program { private static readonly ILog Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); static void Main(string[] args) { LoggingTest(1000); Console.ReadKey(); } private static void LoggingTest(int iterations) { Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < iterations; i++) { Log.Info("Some info logging."); } Console.WriteLine($"Logging of {iterations} iterations took: {sw.ElapsedMilliseconds} ms."); } } }
After updating Windows (1709), performance with caller location information, such as% C% M% L, is about 100 times worse than without. The problem, of course, is related to the update, because after the rollback, the performance returns to its normal state.
Results before upgrading Windows (1709)
w / o% C% M% L: Recording 1000 iterations took: 18 ms.
w% C% M% L: Recording 1000 iterations took: 81 ms.
Results after updating Windows (1709)
w / o% C% M% L: Recording 1000 iterations took: 14 ms.
w% C% M% L: Recording 1000 iterations took: 1502 ms.
Can someone confirm this problem or have an idea what is happening?
I am grateful for any advice on debugging / fixing it. Thanks in advance!
Jezze source share