Exemplo n.º 1
0
        }//end Get()

        public void LogExposedAPIStatistics(string api, string operation)
        {
            try
            {
                var statistics = Get();
                if (statistics == null)
                {
                    return;
                }
                if (!statistics.IsInteresting(_configuration))
                {
                    return;
                }

                statistics.API       = api;
                statistics.Operation = operation;
                statistics.DateTime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff");

                var logText = JsonConvert.SerializeObject(statistics, new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore,
                    Formatting        = Formatting.Indented
                });

                var _monitorLog = _configuration.GetLogger();
                _monitorLog.Info(logText);
            }
            catch (Exception e)
            {
                _genericLog.Error($"{_nameOfThis} - Exception while Logging Back-End Statistics: {e.Message}");
                _genericLog.Debug($"{_nameOfThis} - Exception while Logging Back-End Statistics: {e.StackTrace}");
                if (!ContinueOnError)
                {
                    throw;
                }
            }
        }//end Log()