示例#1
0
        public static void WriteDiagnostic(FlogDetail infoToLog)
        {
            var isWriteDiagnostics =
                Convert.ToBoolean(
                    ConfigurationManager.AppSettings["EnableDiagnostics"]
                    );

            if (!isWriteDiagnostics)
            {
                return;
            }
            _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.Hostname, infoToLog.UserId,
                infoToLog.UserName, infoToLog.CorrelationId,
                infoToLog.AdditionalInfo
                );
        }
示例#2
0
 public static void WriteError(FlogDetail 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,
         "{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.Hostname, infoToLog.UserId,
         infoToLog.UserName, infoToLog.CorrelationId,
         infoToLog.AdditionalInfo
         );
 }
示例#3
0
        public PerfTracker(
            string name, string userId, string userName,
            string location, string product, string layer
            )
        {
            _sw        = Stopwatch.StartNew();
            _infoToLog = new FlogDetail
            {
                Message  = name,
                UserId   = userId,
                UserName = userName,
                Product  = product,
                Layer    = layer,
                Location = location,
                Hostname = Environment.MachineName
            };
            var beginTime = DateTime.Now;

            _infoToLog.AdditionalInfo = new Dictionary <string, object>
            {
                {
                    "Started",
                    beginTime.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture)
                }
            };
        }
示例#4
0
 public static void WriteError(FlogDetail 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, "{@FlogDetail}", infoToLog);
 }
示例#5
0
        public static void WriteDiagnostic(FlogDetail log)
        {
            bool enableDiagnostics = Convert.ToBoolean(Configuration["EnableDiagnostics"]);

            if (!enableDiagnostics)
            {
                return;
            }
            _diagnosticLogger.Write(LogEventLevel.Information, "{@FlogDetail}", log);
        }
示例#6
0
        public static void WriteDiagnostic(FlogDetail infoToLog)
        {
            //var writeDiagnostics = Convert.ToBoolean(ConfigurationManager.AppSettings["EnableDiagnostics"]);
            //if (!writeDiagnostics)
            //{
            //    return;
            //}

            _diagnosticLogger.Write(LogEventLevel.Information, "{@FlogDetail}", infoToLog);
        }
示例#7
0
 public static void WriteUsage(FlogDetail infoToLog)
 {
     _usageLogger.Write(LogEventLevel.Information, // "{@FlogDetail}", infoToLog);
                        "{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.Hostname, infoToLog.UserId,
                        infoToLog.UserName, infoToLog.CorrelationId,
                        infoToLog.AdditionalInfo);
 }
示例#8
0
        public PerfTracker(string name, string userId, string userName, string location, string product, string layer)
        {
            _stopWatch = Stopwatch.StartNew();
            _log       = new FlogDetail()
            {
                Message  = name,
                UserId   = userId,
                UserName = userName,
                Product  = product,
                Layer    = layer,
                Location = location,
                HostName = Environment.MachineName
            };

            var beginTime = DateTime.UtcNow;

            _log.AdditionalInfo = new Dictionary <string, object>()
            {
                { "Started", beginTime.ToString(CultureInfo.InstalledUICulture) }
            };
        }
示例#9
0
 public static void WriteUsage(FlogDetail infoToLog)
 {
     _usageLogger.Write(LogEventLevel.Information, "{@FlogDetail}", infoToLog);
 }
示例#10
0
 public static void WritePerf(FlogDetail infoToLog)
 {
     _perfLogger.Write(LogEventLevel.Information, "{@FlogDetail}", infoToLog);
 }
示例#11
0
 public static void WriteError(FlogDetail infoToLog)
 {
     _errorLogger.Write(LogEventLevel.Information, "{@FlogDetail}", infoToLog);
 }