【问题标题】:Log4net cannot access the passed properties in the conversion patternLog4net 无法访问转换模式中传递的属性
【发布时间】:2018-09-26 17:28:00
【问题描述】:

我在我的所有开发和生产系统中都将 Log4net 写入 RollingFileAppender,并且它已经在多个发布版本中这样做了。我最近更新(即删除并重新安装)安装在销售人员笔记本电脑上的应用程序版本,现在 Log4net 在遇到%property{propname} 转换模式时会中止每个写入操作。第一个%property 项目之前的转换模式中的所有内容(如%date%message)都将正确记录该调用,但之后没有任何内容。

使用ThreadContext Stack传递属性,基本上是这样的:

using (ThreadContext.Stacks["EventID"].Push(eventIDstr))
using (ThreadContext.Stacks["CategoryID"].Push(categoryIDstr))
{
    log.Debug(message, exception);
}

我最近在构建新的开发机器时看到了同样的行为,我认为它已通过我之后执行的 Windows 更新或其他软件包安装解决,但我真的没有具体的线索来解决问题它除了知道它与我的代码或配置文件无关(它们都保持不变)。什么 DLL 或其他文件/程序集可能是罪魁祸首?

【问题讨论】:

  • 您尝试过enabling log4net internal logging 并查看输出吗?
  • 我现在有.... 唯一报告的错误是:ERROR [RollingFileAppender] ErrorCode: GenericFailure. Failed in DoAppend System.TypeLoadException: Could not load type 'System.Security.Claims.ClaimsIdentity' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. That is followed by the exception stack trace up from log4net.Core.LoggingEvent.get_UserName(). 写入了六个日志条目,全部在第一个 %property 项目处被截断。由于在应用更新之前日志记录工作正常,因此我没有看到那么多帮助。

标签: c# logging windows-7 log4net


【解决方案1】:

找到了!安装 .NET Framework 4.5 就成功了。仅使用 Framework 4.0,它不起作用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-01
    • 1970-01-01
    • 2013-06-18
    • 2019-03-09
    • 1970-01-01
    • 2017-05-04
    • 2010-11-09
    • 2015-08-02
    相关资源
    最近更新 更多