예제 #1
0
        //public static bool SetCoreConfigSettingValue(string strKey, string strValue)
        //{
        //    throw (new NotImplementedException());
        //}

        private static void WriteMessage(string message, Exception exception, bool sendEmail)
        {
            var mLog = new StringBuilder();

            mLog.Append(message);
            mLog.Append(CharSeparate);
            AdvException currError = null;

            if (exception != null)
            {
                mLog.AppendFormat("\"{0}\";", exception.Message);
                currError = new AdvException(exception);
                mLog.AppendFormat("\"{0}\";", currError.ToJsonString().Replace("\"", "\"\""));
            }
            else
            {
                mLog.Append("none;none;");
            }

            var hex  = exception as HttpException;
            var code = hex != null?hex.GetHttpCode() : 0;

            switch (code)
            {
            case 0:
                LogErrHttp.Error(mLog.ToString());
                break;

            case 404:
                LogErr404.Error(mLog.ToString());
                break;

            case 500:
                LogErr500.Error(mLog.ToString());
                break;

            default:
                LogErrHttp.Error(mLog.ToString());
                break;
            }

            // Send email
            if (EnableErrorMailNotification && code != 404 && sendEmail)
            {
                if (currError != null)
                {
                    SendMailError(currError);
                }
            }
        }