Exemplo n.º 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
                );
        }
Exemplo n.º 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
         );
 }
Exemplo n.º 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)
                }
            };
        }
Exemplo n.º 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);
 }
Exemplo n.º 5
0
        public static void WriteDiagnostic(FlogDetail log)
        {
            bool enableDiagnostics = Convert.ToBoolean(Configuration["EnableDiagnostics"]);

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

            _diagnosticLogger.Write(LogEventLevel.Information, "{@FlogDetail}", infoToLog);
        }
Exemplo n.º 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);
 }
Exemplo n.º 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) }
            };
        }
Exemplo n.º 9
0
 public static void WriteUsage(FlogDetail infoToLog)
 {
     _usageLogger.Write(LogEventLevel.Information, "{@FlogDetail}", infoToLog);
 }
Exemplo n.º 10
0
 public static void WritePerf(FlogDetail infoToLog)
 {
     _perfLogger.Write(LogEventLevel.Information, "{@FlogDetail}", infoToLog);
 }
Exemplo n.º 11
0
 public static void WriteError(FlogDetail infoToLog)
 {
     _errorLogger.Write(LogEventLevel.Information, "{@FlogDetail}", infoToLog);
 }