如果我这样定义TraceSource
:
private static TraceSource traceSource = new TraceSource("MyTrace");
,然后从代码中发布消息:
traceSource.TraceEvent(TraceEventType.Information, 1, "My message");
,当我的web.config
有以下内容:
<system.diagnostics>
<trace autoflush="true"/>
<sources >
<source name="MyTrace" switchName="Myswitch" >
<listeners>
<add name="textWriterListener" traceOutputOptions="DateTime"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="LogMy_diagnostic.log">
</add>
<remove name="Default" />
</listeners>
</source>
</sources>
<switches>
<add name="Myswitch" value="Verbose" />
</switches>
</system.diagnostics>
我在My_diagnostic.log
跟踪文件中得到的是:
MyTrace Information: 1 : My message
DateTime=2013-03-05T04:45:54.9240441Z
运行此脚本的IIS服务器默认配置了英美代码页。
我的问题是,如果代码页设置为英语以外的任何语言,My_diagnostic.log
跟踪文件中的输出是否相同?日期/时间格式是否与我上面引用的相同?
是的,您在Trace
调用中放置的常量文本没有神奇的翻译。
本地化跟踪消息是不寻常的,因为结果日志预计将由原始开发人员而不是用户使用。另一方面,如果你愿意,你也可以放置本地化的消息。
日期格式为UTC时区的ISO8601,因此无论用户或服务器的文化或时区如何,它都不会改变。