Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOAR Logging for V8 #2935

Merged
merged 7 commits into from
Sep 13, 2018
Merged

MOAR Logging for V8 #2935

merged 7 commits into from
Sep 13, 2018

Conversation

warrenbuckley
Copy link
Contributor

To carry on my other recent related PR's here is some MOAR logging updates & improvements

Adds in some useful Serilog Enrichers from the Serilog.Web.Classic project, but rather than adding that Nupkg directly, I have copied over what I think is useful. As there seems some extra bloat we would not such as a HTTPModule and it potentially capturing/logging sensitve info from FORM DATA.

  • HttpRequestId (Guid)
  • HttpRequestNumber (Increasing int counter)
  • HttpSessionId

This PR also contains an update to keep Serilog properties more consistent, rather than having too many uniquly named properties. So all the timing related log messages now use Duration which will make it alot easier to query for any timing based log where the value is greater than X

Also the very verbose messages for Begin and End request, has now been changed to only log the end of the request and it's timing, as not sure the beginning message was too useful.

Warren Buckley added 5 commits September 6, 2018 20:18
…not sure how useful a log for start & end request IMO (Stephan may think otherwise)
… (we dont want all thex extra bloat such as handlers etc)
…for the duration in milliseconds to be consistently called 'Duration'
@ghost ghost assigned warrenbuckley Sep 6, 2018
@warrenbuckley
Copy link
Contributor Author

@zpqrtbnk as you had concerns over the Request ID stuff I had done previously, please can you look over these implementations to make sure they will work as you would expect.

I have tested with SEQ and are able to see these properties and find related log entries to a request successfully, but a 2nd opinion would be appreciated please :)

@zpqrtbnk
Copy link
Contributor

zpqrtbnk commented Sep 9, 2018

Reviewing - will comment on the code.

Copy link
Contributor

@zpqrtbnk zpqrtbnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments!

.Enrich.With<Log4NetLevelMapperEnricher>()
.Enrich.With<HttpSessionIdEnricher>()
.Enrich.With<HttpRequestNumberEnricher>()
.Enrich.With<HttpRequestIdEnricher>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIC the RequestId enricher will bind a GUID to each request whereas the RequestNumber will bind an INT - both aiming at being a unique identifier for the request - do we actually want both? I realize... during restarts, we may see duplicate INT identifiers whereas GUIDs will always be unique... yet INTs give an idea of order. So maybe having the two is good. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will keep both for now, as you say its easier if you want to quickly see the previous or next requests by increasing/decreasing the INT

@@ -561,7 +561,6 @@ public void Init(HttpApplication app)
//Create a new Request ID/GUID
requestId = Guid.NewGuid();

Logger.Verbose<UmbracoModule>("Begin request [{RequestId}]: {RequestUrl}", requestId, httpContext.Request.Url);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we want to get rid of that one - when debugging it's nice to see which requests are being processed. That being said: we should exclude client-side (css, js...) requests ie anything that we know we don't process - I think there's some code in the module to figure them out. And then, yes, creating a GUID this way is not going to work due to concurrency (one module instance for many requests) - see how the RequestId enricher works, it needs to store the ID in context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can re-use the RequestGUID from the enricher in this start message log and add this log line back in

@@ -605,8 +604,7 @@ public void Init(HttpApplication app)
if (UmbracoContext.Current != null)
{
Logger.Verbose<UmbracoModule>(
"End Request [{RequestId}]: {RequestUrl} ({RequestTotalMilliseconds}ms)",
requestId,
"Request: {RequestUrl} took {Duration}ms",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above. In fact... if you get rid of RequestId here and let the RequestId enricher deal with it, how will it show in the text log? In other words where would the RequestId show, if it's not part of the logged string but added by the enricher? I understand it would show in the JSON blob but what about text?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - will add it back in. I hope people will stop using the old and hard to read .txt file and swap to use the built in logviewer work I am doing, to help them search and query logs instead.

Warren Buckley added 2 commits September 11, 2018 08:44
…ng with logs makes these logs impossible to find
…emplate for text log files for begin & end request verbose logs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants