| | |
| | | /// Log出力
|
| | | /// </summary>
|
| | | /// <param name="ex"></param>
|
| | | public void WriteLog(Exception ex)
|
| | | /// <param name="appendMsg">附加消息</param>
|
| | | public void WriteLog(Exception ex, string appendMsg = "")
|
| | | {
|
| | | //Log出力
|
| | | string msg = ex.Message + "\r\n";
|
| | | string msg = appendMsg == "" ? string.Empty : appendMsg + "\r\n";
|
| | | msg += ex.Message + "\r\n";
|
| | | msg += ex.StackTrace;
|
| | | this.WriteLog(-1, msg);
|
| | | }
|
| | |
| | | {
|
| | | lock (objLock)
|
| | | {
|
| | | //if (div != -1)
|
| | | //{
|
| | | // //暂时只记录异常信息
|
| | | // return;
|
| | | //}
|
| | | if (div != -1 && UserCenterResourse.HideOption.DetailedLog == 0)
|
| | | {
|
| | | //暂时只记录异常信息
|
| | | return;
|
| | | }
|
| | | //Log文件
|
| | | string fileName = this.GetLogFile(div);
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory, fileName);
|
| | |
|
| | | strLog = "[" + DateTime.Now.ToString("yyyyMMdd HH:mm:ss") + "] " + strLog + "\r\n";
|
| | | var sw = new System.IO.StreamWriter(fullName, true, Encoding.UTF8);
|
| | | sw.WriteLine(strLog);
|
| | | sw.Close();
|
| | | sw = null;
|
| | | System.IO.StreamWriter sw = null;
|
| | | try
|
| | | {
|
| | | string fileName = this.GetLogFile(div);
|
| | | string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory, fileName);
|
| | | strLog = "[" + DateTime.Now.ToString("yyyyMMdd HH:mm:ss") + "] " + strLog + "\r\n";
|
| | | sw = new System.IO.StreamWriter(fullName, true, Encoding.UTF8);
|
| | | sw.WriteLine(strLog);
|
| | | }
|
| | | catch { }
|
| | | finally
|
| | | {
|
| | | sw?.Close();
|
| | | sw = null;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | private string GetLogFile(int div)
|
| | | {
|
| | | //加密,因为这是收集数据,最好不让别人知道这是什么最好
|
| | | string fileName = DateTime.Now.ToString("yyyyMMdd");
|
| | | string fileName = UserCenterResourse.UserInfo.Account + "-" + DateTime.Now.ToString("yyyyMMdd");
|
| | | if (div == -1)
|
| | | {
|
| | | fileName += "Log";
|
| | | }
|
| | | else if (div == 1)
|
| | | {
|
| | | fileName += "Error";
|
| | | }
|
| | | fileName = UserCenterLogic.EncryptPassword("4^Olh_3f", fileName);
|
| | | else if (div == 1)
|
| | | {
|
| | | fileName += "Log";
|
| | | }
|
| | | fileName = UserCenterLogic.EncryptPassword(UserCenterResourse.FileEncryptKey, fileName);
|
| | | return fileName;
|
| | | }
|
| | | #endregion
|