Пример #1
0
        private void FinalizeRequestProcessing(IHttpContext ctx, Stopwatch sw, bool ravenUiRequest)
        {
            LogHttpRequestStatsParams logHttpRequestStatsParam = null;

            try
            {
                logHttpRequestStatsParam = new LogHttpRequestStatsParams(
                    sw,
                    ctx.Request.Headers,
                    ctx.Request.HttpMethod,
                    ctx.Response.StatusCode,
                    ctx.Request.Url.PathAndQuery);
            }
            catch (Exception e)
            {
                logger.Warn("Could not gather information to log request stats", e);
            }

            ctx.FinalizeResonse();
            sw.Stop();

            if (ravenUiRequest || logHttpRequestStatsParam == null)
            {
                return;
            }

            LogHttpRequestStats(logHttpRequestStatsParam);
            ctx.OutputSavedLogItems(logger);
        }
Пример #2
0
        private void LogHttpRequestStats(LogHttpRequestStatsParams logHttpRequestStatsParams)
        {
            // we filter out requests for the UI because they fill the log with information
            // we probably don't care about them anyway. That said, we do output them if they take too
            // long.
            if (logHttpRequestStatsParams.Headers["Raven-Timer-Request"] == "true" && logHttpRequestStatsParams.Stopwatch.ElapsedMilliseconds <= 25)
            {
                return;
            }

            var curReq = Interlocked.Increment(ref reqNum);

            logger.DebugFormat("Request #{0,4:#,0}: {1,-7} - {2,5:#,0} ms - {5,-10} - {3} - {4}",
                               curReq,
                               logHttpRequestStatsParams.HttpMethod,
                               logHttpRequestStatsParams.Stopwatch.ElapsedMilliseconds,
                               logHttpRequestStatsParams.ResponseStatusCode,
                               logHttpRequestStatsParams.RequestUri,
                               currentTenantId.Value);
        }