将当前DateTime添加到.config文件中的字符串[XML] [英] Add current DateTime to string in .config file [XML]

查看:78
本文介绍了将当前DateTime添加到.config文件中的字符串[XML]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序在运行时通过将以下内容放入应用程序.config文件来捕获跟踪输出

I have an application that when running captures Trace output by putting the following in the applications .config file

  <system.diagnostics>  
    <trace autoflush="true" indentsize="4">  
      <listeners>  
        <add name="fooListener"   
          type="System.Diagnostics.XmlWriterTraceListener"   
          initializeData="fooTrace.xml"  
          traceOutputOptions="ProcessId, DateTime" />  
        <remove name="Default" />  
      </listeners>  
    </trace>  
  </system.diagnostics>  

我希望输出文件具有当前值,而不是写入  "fooTrace.xml" DateTime附加或添加到" footrace "不幸的是我的XML技能非常有限。

Instead of writing to "fooTrace.xml" I would like the output file to have the current DateTime appended or prepended to "footrace" unfortunately my XML skills are very limited.

谢谢。

推荐答案

Hello Ellipsisware,

Hello Ellipsisware,

您使用的是Trace.WriteLine(" xxx")吗? ?

Are you using like Trace.WriteLine("xxx")?

只有在    style ="font-family:Arial,sans-serif; font-size:13.65px">你调用Trace.TraceError,Trace.TraceInformation或Trace.TraceWarning但是  不是
WriteLine方法。

You could get the DateTime only when you call Trace.TraceError, Trace.TraceInformation or Trace.TraceWarning but not the WriteLine methods.


Best问候,

Best regards,


Drake

Drake


这篇关于将当前DateTime添加到.config文件中的字符串[XML]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆