Esempio n. 1
0
        private static void LogCore(Exception ex, string message, string title, LogSeverity severity,
                                    IDictionary <string, object> additionalInfo, int priority)
        {
            LogEntry MyLog = new LogEntry();

            MyLog.Message       = message;
            MyLog.Title         = title;
            MyLog.Severity      = severity.ToTraceEventType();
            MyLog.EventId       = 0;
            MyLog.Priority      = priority;
            MyLog.AppDomainName = LocalConfig.UnifiedDeployment_Application;

            Log MyRealLog = new Log();

            MyRealLog.AutoTruncateStringProperties = true;
            //int Parsed;
            MyRealLog.LogGUID    = Guid.NewGuid();
            MyRealLog.AppVersion = LocalConfig.ProductVersion;
            try { MyRealLog.EnvLevel = LocalConfig.UnifiedDeployment_Environment; }
            catch { }
            try
            {
                if ((HttpContext.Current != null) && (HttpContext.Current.Request != null) &&
                    (HttpContext.Current.Request.UserHostAddress != null))
                {
                    try { MyRealLog.UserIPAddress = HttpContext.Current.Request.TrueRemoteAddress().ToString(); }
                    catch { MyRealLog.UserIPAddress = HttpContext.Current.Request.UserHostAddress.ToString(); }
                }
            }
            catch { }

            Dictionary <string, object> ExtDictionary;

            if (additionalInfo != null)
            {
                ExtDictionary = new Dictionary <string, object>(additionalInfo);
            }
            else
            {
                ExtDictionary = new Dictionary <string, object>();
            }
            BuildBaseEnvironmentalInfo(ExtDictionary);
            if (ex != null)
            {
                ExtDictionary[EXCEPTION_KEY] = ex;
            }
            MyLog.ExtendedProperties = ExtDictionary;

            //MyLog.SetLogEntity(MyRealLog);
            //_AppLogger.Write(MyLog);
        }