添加时间戳Trace.WriteLine() [英] Add Timestamp to Trace.WriteLine()
本文介绍了添加时间戳Trace.WriteLine()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的C#.net应用程序,我对Trace.WriteLine()的问题 - 方法。我用这个方法很多,并希望我每次使用它时添加时间戳。
In my C# .NET application I have an issue with the Trace.WriteLine()-method. I uses this method alot, and want to add a TimeStamp every time I use it.
相反Trace.WriteLine(DateTime.Now +不对!)的,有没有一种解决方案,其中日期时间是默认?
Instead of Trace.WriteLine(DateTime.Now + " Something wrong!"), is there a solution where the DateTime is on default?
推荐答案
只写你自己的 TraceLine(串MSG)
的方法,并开始打电话了:
Just write your own "TraceLine(string msg)
" method and start calling that:
void TraceLine(string msg, bool OmitDate)
{
if (!OmitDate)
msg = DateTime.Now + " " + msg;
Trace.WriteLine(msg);
}
void TraceLine(string msg) {TraceLine(msg, false);}
这篇关于添加时间戳Trace.WriteLine()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文