【问题标题】:How do I Include the TraceOutputOptions in the output of Enterprise Library Logging如何在 Enterprise Library Logging 的输出中包含 TraceOutputOptions
【发布时间】:2013-03-07 12:28:22
【问题描述】:

这让我很头疼,而且这个库的文档似乎不存在。 我有一个滚动平面文件侦听器...我想将调用堆栈包含在写入侦听器的任何消息中。

 <add name="RollingFileLog"
           fileName="C:\Rainmaker\Logs\SampleArchitectureService.Log"
           ... snipped for brevity
           traceOutputOptions="Callstack" />

我需要在我的格式化程序中包含什么才能显示调用堆栈/跟踪信息。格式化程序在下面

<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, ..."
           name="TextFormatter"
           template="{timestamp(local)}: [{category}/{severity}] - {message} - ****WHATGOES HERE***" />

我已经尝试了所有方法,在扩展属性字典中查找,使用的 {property()} 和 {keyvalue()} 标记也没有文档。

有人可以向我解释一下这个traceOutputOptions 属性是干什么用的,如果是我想的那样,我到底如何访问这些属性。

【问题讨论】:

    标签: logging enterprise-library callstack enterprise-library-5


    【解决方案1】:

    MSDN 页面中的跟踪输出选项

    TraceOutputOptions 属性确定跟踪输出的可选内容。该属性可以在配置文件中设置,也可以在执行期间以编程方式设置,以包含专门用于一段代码的附加数据。例如,您可以将控制台跟踪侦听器的 TraceOutputOptions 属性设置为 TraceOptions.Callstack 以将调用堆栈信息添加到跟踪输出。

    还请记住,并非所有跟踪侦听器都支持它 http://msdn.microsoft.com/en-us/library/system.diagnostics.tracelistener.traceoutputoptions.aspx

    我看到将 CallStack 信息放入文件的唯一方法是通过文本格式化程序中的扩展属性字典。

    template="Extended Properties: {dictionary({key} - {value}{newline})}"
    

    找到一篇有趣的文章,这应该对你有所帮助。 “如何输出 TraceOutputOptions 值” http://entlib.codeplex.com/discussions/344343

    【讨论】:

    • 注意其他有问题的人:如果使用配置文件设置输出选项,文件中的traceOutputOptions设置区分大小写,必须有一个初始的小写't',就像这句话一样.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-22
    • 2012-02-18
    • 2012-01-26
    相关资源
    最近更新 更多