log4net 无法在 MVC 应用程序中使用 log4net appender azure

log4net not working using log4net appender azure in MVC applcation

相同的 log4net appender azure nuget 代码适用于 console app, but not working in MVC application

我正在使用这个 nuget log4net.Appender.Azure 1.1.1

已在 Global.asax 中添加 log4net.Config.XmlConfigurator.Configure(); web.config

  <log4net>
    <!-- Azure Table Appender, uncomment, set proper QueueName and AWS credentials (appSettings) to try it out -->
    <appender name="AzureAppender1" type="log4net.Appender.AzureTableAppender, log4net.Appender.Azure">
      <param name="TableName" value="test" />
      <param name="ConnectionString" value="***" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>

Can anyone know why it is not working ?

我不确定 - 但我会在将表用于大规模日志记录场景时谨慎一些。看看这个 Table Design Guide 中的日志记录反模式。它通常会导致热分区 - 通常情况下使用 Blob 可以更好地支持这种情况。

来了我发现是log4net dll版本的问题。 在 nuget log4net appender azure 版本的 log4net dll 中是 1.2.12 它是旧版本。需要更新到较新的版本 1.2.13

解决了上述问题。