コード例 #1
0
ファイル: UtilLog.cs プロジェクト: myungtw/TheNewOne
        public static void WriteExceptionLog(string strMessage, string strStackTrace, bool blnSendMailFlag = true)
        {
            StringBuilder       pl_objSB = new StringBuilder();
            NameValueCollection pl_objSV = HttpContext.Current.Request.ServerVariables;
            string pl_strLogName         = string.Empty;
            string pl_strFilePath        = HttpContext.Current.Request.FilePath;

            pl_objSB.AppendLine("HTTP_USER_AGENT : " + pl_objSV.Get("HTTP_USER_AGENT"));
            pl_objSB.AppendLine("REMOTE_ADDR : " + pl_objSV.Get("REMOTE_ADDR"));
            pl_objSB.AppendLine(string.Format("PAGE : {0} {1}", pl_objSV.Get("REQUEST_METHOD"), pl_objSV.Get("URL")));
            pl_objSB.AppendLine("Exception Time : " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            pl_objSB.AppendLine("Exception Messase : " + strMessage);
            pl_objSB.AppendLine("Exception StackTrace : ");
            pl_objSB.AppendLine(strStackTrace);
            pl_objSB.AppendLine();

            pl_strLogName = string.Format("Exception_{0}.txt", DateTime.Now.ToString("yyyyMMdd"));

            FormatLog(UserGlobal.BOQ_EXCEPTION_LOGPATH, pl_strLogName, pl_objSB.ToString());

            if (blnSendMailFlag)
            {
                UtilMail.SendExceptionMail(strMessage, strStackTrace);
            }
        }
コード例 #2
0
ファイル: UtilLog.cs プロジェクト: myungtw/TheNewOne
        ///----------------------------------------------------------------------
        /// <summary>
        /// Exception 로그 파일 포맷
        /// </summary>
        ///----------------------------------------------------------------------
        public static void WriteExceptionLog(string strMethodName, string strLogName, string strLogMsg, bool blnSendMailFlag = true)
        {
            string pl_strLogName    = string.Empty;
            string pl_strRetString  = string.Empty;
            string pl_strRemoteAddr = HttpContext.Current.Request.ServerVariables.Get("REMOTE_ADDR");
            string pl_strFilePath   = HttpContext.Current.Request.FilePath;

            pl_strLogName   = string.Format("{0}_{1}.txt", strLogName, DateTime.Now.ToString("yyyyMMdd"));
            pl_strRetString = string.Format("[{0}] [{1}] [{2}] LogMsg : {3}", pl_strRemoteAddr, pl_strFilePath, strMethodName, strLogMsg);

            FormatLog(UserGlobal.BOQ_EXCEPTION_LOGPATH, pl_strLogName, pl_strRetString);

            if (blnSendMailFlag)
            {
                UtilMail.SendExceptionMail(strLogMsg, "");
            }
        }