Gets the same HttpRequestId from the Enricher to use in the message template for text log files for begin & end request verbose logs

This commit is contained in:
Warren Buckley
2018-09-11 09:04:29 +01:00
parent 4b47943e05
commit ed94ea485d

View File

@@ -21,6 +21,7 @@ using Umbraco.Core.Security;
using Umbraco.Core.Services;
using Umbraco.Web.Composing;
using Umbraco.Web.PublishedCache;
using Umbraco.Core.Logging.Serilog.Enrichers;
namespace Umbraco.Web
{
@@ -558,8 +559,12 @@ namespace Umbraco.Web
{
var httpContext = ((HttpApplication) sender).Context;
//Create a new Request ID/GUID
requestId = Guid.NewGuid();
var httpRequestId = Guid.Empty;
HttpRequestIdEnricher.TryGetCurrentHttpRequestId(out httpRequestId);
Logger.Verbose<UmbracoModule>("Begin request [{HttpRequestId}]: {RequestUrl}",
httpRequestId,
httpContext.Request.Url);
BeginRequest(new HttpContextWrapper(httpContext));
};
@@ -603,8 +608,12 @@ namespace Umbraco.Web
if (UmbracoContext.Current != null)
{
var httpRequestId = Guid.Empty;
HttpRequestIdEnricher.TryGetCurrentHttpRequestId(out httpRequestId);
Logger.Verbose<UmbracoModule>(
"Request: {RequestUrl} took {Duration}ms",
"End request [{HttpRequestId}]: {RequestUrl} took {Duration}ms",
httpRequestId,
httpContext.Request.Url,
DateTime.Now.Subtract(UmbracoContext.Current.ObjectCreated).TotalMilliseconds);
}