Beispiel #1
0
 public static void WritePerf(C3logDetail infoToLog)
 {
     //_perfLogger.Write(LogEventLevel.Information, "{@C3oglogDetail}", infoToLog);
     _perfLogger.Write(LogEventLevel.Information,
                       "{Timestamp}{Message}{Layer}{Location}{Product}" +
                       "{CustomException}{ElapsedMilliseconds}{Exception}{Hostname}" +
                       "{UserId}{UserName}{CorrelationId}{AdditionalInfo}",
                       infoToLog.Timestamp, infoToLog.Message,
                       infoToLog.Layer, infoToLog.Location,
                       infoToLog.Product, infoToLog.CustomException,
                       infoToLog.ElapsedMilliseconds, infoToLog.Exception?.ToBetterString(),
                       infoToLog.UserName, infoToLog.CorrelationId,
                       infoToLog.AdditionalInfo
                       );
 }
Beispiel #2
0
 public static void WriteError(C3logDetail infoToLog)
 {
     if (infoToLog.Exception != null)
     {
         var procName = FindProcName(infoToLog.Exception);
         infoToLog.Location = string.IsNullOrEmpty(procName) ? infoToLog.Location : procName;
         infoToLog.Message  = GetMessageFromException(infoToLog.Exception);
     }
     //_errorLogger.Write(LogEventLevel.Information, "{@C3oglogDetail}", infoToLog);
     _errorLogger.Write(LogEventLevel.Information,
                        "{Timestamp}{Message}{Layer}{Location}{Product}" +
                        "{CustomException}{ElapsedMilliseconds}{Exception}{Hostname}" +
                        "{UserId}{UserName}{CorrelationId}{AdditionalInfo}",
                        infoToLog.Timestamp, infoToLog.Message,
                        infoToLog.Layer, infoToLog.Location,
                        infoToLog.Product, infoToLog.CustomException,
                        infoToLog.ElapsedMilliseconds, infoToLog.Exception?.ToBetterString(),
                        infoToLog.UserName, infoToLog.CorrelationId,
                        infoToLog.AdditionalInfo
                        );
 }
Beispiel #3
0
        public PerfTracker(string name, string userId, string userName,
                           string location, string product, string layer)
        {
            _sw        = Stopwatch.StartNew();
            _infoToLog = new C3logDetail()
            {
                Message   = name,
                UserName  = userName,
                Timestamp = DateTime.Now,
                Product   = product,
                Layer     = layer,
                Location  = location,
                Hostname  = Environment.MachineName
            };

            var beginTime = DateTime.Now;

            _infoToLog.AdditionalInfo = new Dictionary <string, object>()
            {
                { "Started", beginTime.ToString(CultureInfo.InvariantCulture) }
            };
        }
Beispiel #4
0
        public static void WriteDiagnostic(C3logDetail infoToLog)
        {
            var writeDiagnostics = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableDiagnostics"]);

            if (!writeDiagnostics)
            {
                return;
            }

            //_diagnosticLogger.Write(LogEventLevel.Information, "{@C3oglogDetail}", infoToLog);
            _diagnosticLogger.Write(LogEventLevel.Information,
                                    "{Timestamp}{Message}{Layer}{Location}{Product}" +
                                    "{CustomException}{ElapsedMilliseconds}{Exception}{Hostname}" +
                                    "{UserId}{UserName}{CorrelationId}{AdditionalInfo}",
                                    infoToLog.Timestamp, infoToLog.Message,
                                    infoToLog.Layer, infoToLog.Location,
                                    infoToLog.Product, infoToLog.CustomException,
                                    infoToLog.ElapsedMilliseconds, infoToLog.Exception?.ToBetterString(),

                                    infoToLog.UserName, infoToLog.CorrelationId,
                                    infoToLog.AdditionalInfo
                                    );
        }