【发布时间】: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