Log4Net.Error抛出VerificationException - 操作可能会破坏运行时的稳定性

时间:2013-07-13 03:54:08

标签: log4net

当我们使用log4net记录错误/致命消息时,我们遇到了这个问题。

  

System.Security.VerificationException:操作可能破坏稳定性   运行。 at log4net.Core.LogImpl.Fatal(Object message,Exception   例外)

奇怪的是,只有当我们记录为错误/致命,信息和调试消息时,才会发生这种情况。由于这个例外,真正的异常被掩盖了,这使得我们很难在部署的环境中进行调试。

我试过在网上搜索但无济于事。任何帮助表示赞赏。

环境详情:

IIS 7.5 / Win 2008 R2
.Net 4.0
MVC3 and WCF applications

以下是日志记录配置 -

   <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,   log4net"/>
      </configSections>  
      <log4net>
      <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
        <file value="C:\Logs\ApplicationServices.log" />
        <staticLogFileName value="true" />
        <appendToFile value="true" />
        <datePattern value="yyyyMMdd" />
        <rollingStyle value="Date" />
        <filter type="log4net.Filter.LevelRangeFilter">
        <acceptOnMatch value="true" />
        <levelMin value="DEBUG" />
        <levelMax value="FATAL" />
        </filter>
        <layout type="log4net.Layout.PatternLayout">      
          <conversionPattern value="${COMPUTERNAME} %date %-5level %class.%method - %message%newline"/>
        </layout>
      </appender>
      <root>
        <level value="DEBUG"/>
        <appender-ref ref="RollingLogFileAppender" />
      </root>
    </log4net>
    </configuration>

1 个答案:

答案 0 :(得分:0)

System.Security.VerificationException:操作可能会破坏运行时的稳定性。如果.Net Security系统将代码识别为不安全类型,则抛出此异常。

如果针对log4net.dll版本1.2.11(此时为最新版本)运行peverify.exe,则会出现以下错误。

log4net.Plugin.RemoteLoggingServerPlugin::Attach][offset 0x0000002C] Method is not visible.
1 Error(s) Verifying log4net.dll.

您可以在stackoverflow thread中找到有关如何使log4net代码通过验证的更多详细信息。