解决 ILogFormatter 的企业库日志记录跟踪侦听器扩展问题
我已经被这个问题困扰了很长一段时间,但我似乎找不到我错过的东西。 我为 Enterprise Library 5.0 的 Logging 应用程序块编写了一个自定义跟踪侦听器组件,该组件可以工作,但配置的 ILogFormatter 无法解析,因此当我的组件处理它时,我总是得到基本字符串文本。 我在企业库源代码中看到他们使用“Container.ResolvedIfNotNull()”方法。这似乎对我不起作用。我需要它写出自定义格式的字符串供我的组件使用。你知道,不仅仅是消息,还有时间戳、机器名、线程 ID 等。
有人知道如何解决这个问题吗?
提前致谢。
I have been sitting with a problem for quite a while now and I just can't seem to find what I'm missing.
I have written a custom trace listener component for Enterprise Library 5.0 for the Logging application block which works but the configured ILogFormatter just won't resolve and so I always end up with the basic string text when it gets handled by my component.
I saw in the enterprise library source code that they use the "Container.ResolvedIfNotNull()" method. It doesn't seem to work for me. I need it to write out a custom formatted string for my component to use. You know, not just the message but the timestamp, machinename, threadId, etc.
Does anyone have any ideas on how to fix this?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就像我在这个网站上提到的:http://entlib.codeplex.com/discussions/261749
当您在
TraceListener
数据类中创建CreationExpression
时,请确保您有一个平面构造函数定义。换句话说,不要返回:只需将其放在
MyTraceListener
的构造函数中即可:Like I've mentioned on this site: http://entlib.codeplex.com/discussions/261749
When you create your
CreationExpression
in theTraceListener
data class make sure you have a flat constructor definition. To put it in other words, don't return:just have it in the constructor of the
MyTraceListener
: