Пример #1
0
        static void Main(string[] args)
        {
            var fd = GetLogDetails("starting application", null);

            Hlogger.WriteDiagonistic(fd);

            var tracker = new PerfTracker("CrxConsole_Execution", "", fd.UserName, fd.Location, fd.Product, fd.Layer);

            try
            {
                var ex = new Exception("Something bad has happend!");
                ex.Data.Add("input param", "nothing to see here");
                throw ex;
            }
            catch (Exception ex)
            {
                fd = GetLogDetails("", ex);
                Hlogger.WriteError(fd);
            }
            fd = GetLogDetails("Used Hylogger Console", null);
            Hlogger.WriteUsage(fd);

            fd = GetLogDetails("stopping app", null);
            Hlogger.WriteDiagonistic(fd);

            tracker.Stop();
        }
Пример #2
0
        public static void LogWebDiagnostic(string product, string layer, string message,
                                            Dictionary <string, object> diagnosticInfo = null)
        {
            var writeDiagnostics = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableDiagnostics"]);

            if (!writeDiagnostics)  // doing this to avoid going through all the data - user, session, etc.
            {
                return;
            }

            string userId, userName, location;
            var    webInfo = GetWebFloggingData(out userId, out userName, out location);

            if (diagnosticInfo != null)
            {
                foreach (var key in diagnosticInfo.Keys)
                {
                    webInfo.Add(key, diagnosticInfo[key]);
                }
            }

            var diagInfo = new HylogDetails()
            {
                Product        = product,
                Layer          = layer,
                Location       = location,
                TimeStamp      = DateTime.Now,
                UserId         = userId,
                UserName       = userName,
                HostName       = Environment.MachineName,
                CorrelationId  = HttpContext.Current.Session.SessionID,
                Message        = message,
                AdditionalInfo = webInfo
            };

            Hlogger.WriteDiagonistic(diagInfo);
        }