微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Silverlight写错误日志

说明是在基于网站的Silverlight项目
日志是记录在网站工程的目录,部署到IIS上之后,日志是下载IIS虚拟目录下的

参考代码


    public class MyLog
    {
        public static void WriteErrLog(string strErrMod,string strErrDesc)
        {
            StreamWriter sw;
            string strErrLog =
                System.AppDomain.CurrentDomain.BaseDirectory + @"gErr.txt";   //获取写日志的路径             if (File.Exists(strErrLog))             {                 FileInfo oFile = new FileInfo(strErrLog);                 if (oFile.Length > 1024000)                 {                     oFile.Delete();                 }             }             if (File.Exists(strErrLog))             {                 sw = File.AppendText(strErrLog);             }             else             {                 sw = File.CreateText(strErrLog);             }             string strDate = "出错时间:" + string.Format("{0:yyyy-MM-dd HH:mm:ss}",DateTime.Now);             string strErrMoudle = "出错模块:" + strErrMod;             string strErrDescOut = "错误原因:" + strErrDesc;             sw.WriteLine(strDate);             sw.WriteLine(strErrMoudle);             sw.WriteLine(strErrDescOut);             sw.WriteLine("===================================================================");             sw.Flush();             sw.Close();         }     }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐