椤圭洰鍙兘浼氱敤鍒扮殑杈呭姪鏂规硶
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了椤圭洰鍙兘浼氱敤鍒扮殑杈呭姪鏂规硶相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%5cn' title=' '>
toe sha 鏂规硶 catch path datetime sage demo鍐欐棩蹇楃殑鏂规硶锛?/p>
public static void WriteLog(Exception e) { try { var fileName = DateTime.Now.ToString("HH:mm:ss").Replace(鈥?鈥? 鈥榑鈥?.Replace(鈥?鈥?鈥榑鈥?; var physicalPath = "E:/鏈満demo/ConsoleApp2/log/"+DateTime.Now.ToString("yyyy-MM-dd")+"/Exceptionlog_" + fileName + ".log"; if (!File.Exists(physicalPath)) { var fcreat = File.Create(physicalPath); fcreat.Close(); } using (FileStream aFile = new FileStream(physicalPath, FileMode.Open)) { StreamReader sr = new StreamReader(aFile, Encoding.GetEncoding("GB2312")); var content = sr.ReadToEndAsync().Result; #region 鍐欏叆寮傚父淇℃伅 using (StreamWriter sw = new StreamWriter(aFile, Encoding.UTF8)) { sw.Write(content + " " + DateTime.Now.ToString() + "锛歕r " + e.Message.ToString()); //杩欓噷鏄啓鍏ョ殑鍐呭 sw.Flush(); sw.Close(); } #endregion sr.Close(); } } catch (Exception ex) { throw (ex); } }
銆€銆€
以上是关于椤圭洰鍙兘浼氱敤鍒扮殑杈呭姪鏂规硶的主要内容,如果未能解决你的问题,请参考以下文章
浣跨敤Python杩囩▼涓亣鍒扮殑涓€浜涘潙鍙婂叾瑙e喅鏂规硶锛堟寔缁洿鏂帮級
瑙e喅java web 椤圭洰鍙戝竷webservice鎺ュ彛