StringBuilder SB = new StringBuilder();
if (LogStream.Length < 21)
SB.AppendLine("<ERRORLOG>");
else
LogStream.Position = LogStream.Length - 13;
SB.AppendLine(" <LOG TIME=\"{0}\" SOURCE=\"{1}\">");
SB.AppendLine(" <EXCEPTION>{2}</EXCEPTION>");
SB.AppendLine(" <MESSAGE>{3}</MESSAGE>");
SB.AppendLine(" <SOURCE>{4}</SOURCE>");
SB.AppendLine(" <STACK>{5}</STACK>");
SB.AppendLine(" <TARGETSITE>{6}</TARGETSITE>");
SB.AppendLine(" </LOG>");
SB.AppendLine("</ERRORLOG>"); // End the xml file
Log.Write(
string.Format(SB.ToString(),
DateTime.Now.ToString("HH:mm:ss"),
Source.ToString(),
Ex.ToString(),
Ex.Message,
Ex.Source,
Ex.StackTrace,
Ex.TargetSite.Name));
SB = null;
}
catch (Exception Exn)
{ }
finally
{
if (Log != null) Log.Close(); Log = null;
if (LogStream != null) LogStream.Close(); LogStream = null; C#的FTP服务器软件系统的设计与实现(15):http://www.751com.cn/jisuanji/lunwen_5865.html