If I define the TraceSource
as such:
如果我这样定义TraceSource:
private static TraceSource traceSource = new TraceSource("MyTrace");
and then post messages from the code:
然后从代码中发布消息:
traceSource.TraceEvent(TraceEventType.Information, 1, "My message");
when my web.config
has the following:
当我的web.config具有以下内容时:
<system.diagnostics>
<trace autoflush="true"/>
<sources >
<source name="MyTrace" switchName="Myswitch" >
<listeners>
<add name="textWriterListener" traceOutputOptions="DateTime"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="Log\My_diagnostic.log">
</add>
<remove name="Default" />
</listeners>
</source>
</sources>
<switches>
<add name="Myswitch" value="Verbose" />
</switches>
</system.diagnostics>
what I'd get in the My_diagnostic.log
trace file is this:
我在My_diagnostic.log跟踪文件中得到的是:
MyTrace Information: 1 : My message
DateTime=2013-03-05T04:45:54.9240441Z
The IIS server that this script runs on has English-US code page configured by default.
运行此脚本的IIS服务器默认配置了英语 - 美国代码页。
My question is, will the output in the My_diagnostic.log
trace file be the same if the code page is set to any language other than English? And also will the date/time format be the same as I quoted above?
我的问题是,如果代码页设置为除英语之外的任何语言,My_diagnostic.log跟踪文件中的输出是否相同?日期/时间格式也与我上面引用的相同吗?
1 个解决方案
#1
2
Yes, there is no magic translation of your constant text that your put in Trace
call.
是的,您在跟踪调用中放置的常量文本没有神奇的翻译。
It is unusual to localize trace messages as resulting logs are expected to be used by original developers and not the user. On other hand you can put localized messages if you want to.
本地化跟踪消息是不常见的,因为预期结果日志将由原始开发人员而不是用户使用。另一方面,如果您愿意,可以放置本地化的消息。
The date format is ISO8601 in UTC time zone, so it will not change irrespective of user's or server's culture or time zone.
日期格式为UTC时区的ISO8601,因此无论用户或服务器的文化或时区如何,它都不会更改。
#1
2
Yes, there is no magic translation of your constant text that your put in Trace
call.
是的,您在跟踪调用中放置的常量文本没有神奇的翻译。
It is unusual to localize trace messages as resulting logs are expected to be used by original developers and not the user. On other hand you can put localized messages if you want to.
本地化跟踪消息是不常见的,因为预期结果日志将由原始开发人员而不是用户使用。另一方面,如果您愿意,可以放置本地化的消息。
The date format is ISO8601 in UTC time zone, so it will not change irrespective of user's or server's culture or time zone.
日期格式为UTC时区的ISO8601,因此无论用户或服务器的文化或时区如何,它都不会更改。