コード例 #1
0
        private void GenerateApiErrors()
        {
            var random         = new Random();
            var numberOfErrors = random.Next(1, 10);

            for (int i = 0; i < numberOfErrors; i++)
            {
                var randomBrand = GetRandomBrand();

                var structuredIncentivesLog = new IncentivesError
                {
                    BrandName   = randomBrand,
                    IncentiveId = Guid.NewGuid(),
                    DateTime    = DateTime.UtcNow,
                    App         = "Incentives"
                };

                this.logger.Error("Generated Error log. {@structuredLog}", structuredIncentivesLog);
            }
        }
コード例 #2
0
        private void GenerateErrorLogs()
        {
            var random         = new Random();
            var numberOfErrors = random.Next(1, 10);

            for (int i = 0; i < numberOfErrors; i++)
            {
                var randomBrand = GetRandomBrand();

                var structuredIncentivesLog = new IncentivesError
                {
                    BrandName   = randomBrand,
                    IncentiveId = Guid.NewGuid(),
                    DateTime    = DateTime.UtcNow,
                    App         = "Incentives",
                    Message     = "The specified argument (resources) cannot be empty.Parameter name: resources",
                    StackTract  = "at System.Requires.NotNullOrEmpty[T](IEnumerable`1 collection, String name)" +
                                  "at AM.Resources.ResourceCollection`2..ctor(IEnumerable`1 resources)" +
                                  "at AM.Resources.Extensions.EnumerableExtensions.AsResourceCollection[TResource, TKey](IEnumerable`1 resources)" +
                                  "at AM.Resources.Extensions.EnumerableExtensions.AsResourceCollection[TResource, TKey](IEnumerable`1 resources, String method, String requestUri)" +
                                  "at Microsoft.AspNetCore.Mvc.ResourceCollectionOkResult`2.ExecuteResultAsync(ActionContext context)" +
                                  "at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result)" +
                                  "at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultFilters()" +
                                  "at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()" +
                                  "at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)" +
                                  "at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State & next, Scope & scope, Object & state, Boolean & isCompleted)" +
                                  "at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()" +
                                  "at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()" +
                                  "at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)" +
                                  "at AM.Metrics.AspNetCore.Middleware.ErrorTrackingMiddleware.InvokeAsync(HttpContext context)" +
                                  "at AM.Metrics.AspNetCore.Middleware.ContentLengthTrackingMiddleware.InvokeAsync(HttpContext context)" +
                                  "at AM.Metrics.AspNetCore.Middleware.ActiveRequestTrackingMiddleware.InvokeAsync(HttpContext context)" +
                                  "at AM.Metrics.AspNetCore.Middleware.ApdexTrackingMiddleware.InvokeAsync(HttpContext context)" +
                                  "at AM.Metrics.AspNetCore.Middleware.RequestTrackingMiddleware.InvokeAsync(HttpContext context)" +
                                  "at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)"
                };

                this.logger.Error("Generated Error log. {@structuredLog}", structuredIncentivesLog);
            }
        }