Пример #1
0
        public static void Report(System.Type type, System.Collections.Hashtable parameters, System.Exception ex)
        {
            LogTypes enmLogType = LogTypes.Both;

            try
            {
                byte bytLogType = System.Convert.ToByte(ApplicationEdit.GetValue("DefaultLogType", "0"));
                enmLogType = (LogTypes)bytLogType;
            }
            catch { }

            Report(type, parameters, ex, enmLogType);
        }
Пример #2
0
        private static bool LogToFile(string message)
        {
            bool blnResult = false;

            string strLogPathName =
                ApplicationEdit.GetValue("RootRelativeApplicationLogPathName");

            if (string.IsNullOrEmpty(strLogPathName) == false)
            {
                // **************************************************
                if ((System.Web.HttpContext.Current != null) && (System.Web.HttpContext.Current.Application != null))
                {
                    strLogPathName =
                        System.Web.HttpContext.Current.Server.MapPath(strLogPathName);

                    System.Web.HttpContext.Current.Application.Lock();
                }
                // **************************************************

                System.IO.StreamWriter oStreamWriter = null;
                try
                {
                    oStreamWriter =
                        new System.IO.StreamWriter(strLogPathName, true, System.Text.Encoding.UTF8);

                    oStreamWriter.WriteLine(message);
                    oStreamWriter.Close();

                    blnResult = true;
                }
                catch { }
                finally
                {
                    if (oStreamWriter != null)
                    {
                        oStreamWriter.Dispose();
                        oStreamWriter = null;
                    }
                }

                // **************************************************
                if ((System.Web.HttpContext.Current != null) && (System.Web.HttpContext.Current.Application != null))
                {
                    System.Web.HttpContext.Current.Application.UnLock();
                }
                // **************************************************
            }
            return(blnResult);
        }