Example #1
0
        public LogInfo()
        {
            LogGUID = Guid.NewGuid().ToString();
            BypassBuffering = false;
            LogProperties = new LogProperties();
            LogPortalID = -1;
            LogPortalName = "";
            LogUserID = -1;
            LogEventID = -1;
            LogUserName = "";
			Exception = new ExceptionInfo();
        }
Example #2
0
		/// <summary>
		/// Gets the exception info.
		/// </summary>
		/// <param name="e">The exception.</param>
		/// <returns>Exception info.</returns>
        public static ExceptionInfo GetExceptionInfo(Exception e)
        {
            var objExceptionInfo = new ExceptionInfo();

            while (e.InnerException != null)
            {
                e = e.InnerException;
            }
            var st = new StackTrace(e, true);
            StackFrame sf = st.GetFrame(0);
            if (sf != null)
            {
                try
                {
                    //Get the corresponding method for that stack frame.
                    MemberInfo mi = sf.GetMethod();
                    //Get the namespace where that method is defined.
                    string res = mi.DeclaringType.Namespace + ".";
                    //Append the type name.
                    res += mi.DeclaringType.Name + ".";
                    //Append the name of the method.
                    res += mi.Name;
                    objExceptionInfo.Method = res;
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);

                    objExceptionInfo.Method = "N/A - Reflection Permission required";
                }
                if (!String.IsNullOrEmpty(sf.GetFileName()))
                {
                    objExceptionInfo.FileName = sf.GetFileName();
                    objExceptionInfo.FileColumnNumber = sf.GetFileColumnNumber();
                    objExceptionInfo.FileLineNumber = sf.GetFileLineNumber();
                }
            }
            return objExceptionInfo;
        }
Example #3
0
        public static ExceptionInfo GetExceptionInfo( Exception e )
        {
            ExceptionInfo objExceptionInfo = new ExceptionInfo();

            while( !( e.InnerException == null ) )
            {
                e = e.InnerException;
            }

            StackTrace st = new StackTrace( e, true );
            StackFrame sf = st.GetFrame( 0 );

            try
            {
                //Get the corresponding method for that stack frame.
                MemberInfo mi = sf.GetMethod();
                // Get the namespace where that method is defined.
                string res = mi.DeclaringType.Namespace + ".";
                // Append the type name.
                res += mi.DeclaringType.Name + ".";
                // Append the name of the method.
                res += mi.Name;
                objExceptionInfo.Method = res;
            }
            catch( Exception )
            {
                objExceptionInfo.Method = "N/A - Reflection Permission required";
            }

            if( sf.GetFileName() != "" )
            {
                objExceptionInfo.FileName = sf.GetFileName();
                objExceptionInfo.FileColumnNumber = sf.GetFileColumnNumber();
                objExceptionInfo.FileLineNumber = sf.GetFileLineNumber();
            }

            return objExceptionInfo;
        }