【问题标题】:Log4Net.Error throws VerificationException - Operation could destabilize the runtimeLog4Net.Error 引发 VerificationException - 操作可能会破坏运行时
【发布时间】:2013-07-13 03:54:07
【问题描述】:

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

System.Security.VerificationException:操作可能会破坏 运行。在 log4net.Core.LogImpl.Fatal(对象消息,异常 例外)

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

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

环境详情:

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>

【问题讨论】:

  • 您能给我们举一个抛出的日志调用示例吗?此日志记录调用是否在由 System.Security.VerificationException 引起的捕获中完成?

标签: log4net


【解决方案1】:

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代码通过验证的细节。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-22
    相关资源
    最近更新 更多