数据结构和算法02--log的写法

本文使用log4cpp作为log的方法,因为方便log管理并且便于移植.

 

常用log写法列举:

1:只从调试器上看

  trace,afxTrace

2:

  OutputDebugString

3:

  cout,printf

4:

  WriteConsole

5:

  fopen,fwrite,fclose

 

 

另:

c#

1:Console.Write

2:写入文件

http://blogs.msdn.com/csharpfaq/archive/2006/03/27/562555.aspx

public void LogMessageToFile(string msg)

{

System.IO.StreamWriter sw = System.IO.File.AppendText("My Log File.txt");

string logLine = System.String.Format("{0:G}: {1}.", System.DateTime.Now, msg);
sw.WriteLine(logLine);

sw.Close();
}

posted @ 2009-11-20 11:04  vcommon  阅读(306)  评论(0编辑  收藏  举报