コード例 #1
0
        //#endregion
        //#region 错误消息
        /// <summary>
        /// 显示详细的出错信息
        /// </summary>
        /// <param name="ex">Exception ex</param>
        /// <returns></returns>
        public static string Expand(Exception ex)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("*******************************************************************************************************");
            if (!HttpContext.Current.IsNull())
            {
                sb.AppendLine(string.Format("* DateTime :   {0}	IP:{1}	MemberID:{2}	OS:{3}	Brower:{4}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Request2.GetIP(), "", Request2.GetOS(), Request2.GetBrowser()));
                sb.AppendLine("* Url      :   " + Request2.GetUrl());
                sb.AppendLine("* Request  :   " + Request2.GetRequest());
            }
            _expandException(ex, 1, sb);
            sb.AppendLine("*******************************************************************************************************");
            sb.AppendLine("");
            return(sb.ToString());
        }
コード例 #2
0
ファイル: SimpleLog.cs プロジェクト: wangscript007/Pub.Class
        /// <summary>
        /// 写日志
        /// </summary>
        /// <param name="msg">消息</param>
        /// <param name="encoding">编码</param>
        /// <returns>true/false</returns>
        public bool Write(string msg, Encoding encoding = null)
        {
            string        LogFile = LogPath.TrimEnd('\\') + @"\Log_" + DateTime.Now.ToString("yyyyMMdd") + ".log";
            StringBuilder sb      = new StringBuilder();

            sb.AppendLine("/*******************************************************************************************************");
            sb.AppendLine(string.Format("* DateTime:{0}{1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), HttpContext.Current.IsNotNull() ? ("	IP:{0}	OS:{1}	Brower:{2}".FormatWith(Request2.GetIP(), Request2.GetOS(), Request2.GetBrowser())) : ""));
            if (HttpContext.Current.IsNotNull())
            {
                sb.AppendLine("* Url:" + Request2.GetUrl());
                sb.AppendLine("* Data:" + Request2.GetRequestInputStream());
            }
            sb.AppendLine("* Message:" + msg);
            sb.AppendLine("*******************************************************************************************************/");
            sb.AppendLine("");
            return(FileDirectory.FileWrite(LogFile, sb.ToString(), encoding ?? Encoding.UTF8));
        }