-
Notifications
You must be signed in to change notification settings - Fork 202
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
Request logging path based filtering #100
Comments
Thanks for the feedback, Jake 👍 I've been anticipating needing to add some functionality along these lines, need to give it some more thought, though. Will try to loop back to this before we RTM the 3.0 version. |
Just a note, this didn't make it into 3.0, but would be good to consider further down the track. In the meantime, .Filter.ByExcluding("RequestPath not in ['/', '/ping', '/live', '/ready']") |
@jakejscott In our projects (we use custom middleware for request logging), we did just what you said, a variety of delegates for filters and other settings in the |
3.1.0 includes a new configuration option that works for this, although it's a little bit subtle: LogEventLevel GetLevel(HttpContext ctx, double elapsedMS, Exception ex)
{
var path = GetPath(httpContext);
switch (path)
{
case "/":
case "/ping":
case "/live":
case "/ready":
return LogEventLevel.Debug;
}
return ex != null || ctx.Response.StatusCode > 499 :
LogEventLevel.Error :
LogEventLevel.Information;
}
app.UseSerilogRequestLogging(opts => opts.GetLevel = GetLevel); #140 is queued up to release this, but there's already a |
Yes, I saw it. Over time the options tend to fill up with new settings, as numerous consumers always have different behavior requirements. |
@sungam3r yes, there's always a delicate balance - this one made the bar because of (IIRC) four requests for it within the first month of shipping the package. |
Hi @nblumhardt just wanted to suggest a feature for the request logging middleware...
We've been using an earlier version of this middleware that I think you blogged about at some point. Anyway, one thing that we did is made it possible to filter out certain paths for example the health check endpoints. We send our logs to Sumologic and the bills can get expensive so we reduced logging by getting rid of these logs. We just change the log level to Debug.
For example:
Would you be interested in this idea? An optional callback function in the
RequestLoggingOptions
which could decide the log level or to not log at all. The other way it could be done is by extendingRequestLoggingMiddleware
with a subclass perhaps.The text was updated successfully, but these errors were encountered: