Request logging path based filtering
See original GitHub issueHi @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:
var path = GetPath(httpContext);
switch (path)
{
case "/":
case "/ping":
case "/live":
case "/ready":
level = LogEventLevel.Debug;
break;
}
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 extending RequestLoggingMiddleware
with a subclass perhaps.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Advanced Logging for IIS - Log Filtering
This section describes how to create a filter for a log definition that captures requests based on multiple criteria. The example in this ......
Read more >Spring - Log Incoming Requests
In this quick tutorial, we'll learn the basics of logging incoming requests using Spring Boot's logging filter.
Read more >Spring Boot - How to log all requests and responses with ...
In order to log all the requests with input parameters and body, we can use filters and interceptors. But while using a filter...
Read more >java - Filter for logging http request parameters
I have written a filter that intercepts http calls and logs request parameters. public void doFilter(ServletRequest request, ServletResponse ...
Read more >A Guide to Log Filtering: Tips for IT Pros
In this post, I'll show how you can filter log messages and make them useful for solving your application and infrastructure problems.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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()
is a reasonable workaround in many cases. For example, using Serilog.Filters.Expressions, your health check endpoints could be excluded with:3.1.0 includes a new configuration option that works for this, although it’s a little bit subtle:
#140 is queued up to release this, but there’s already a
-dev
build on NuGet to try. If it works for you, I think in the spirit of minimalism we should call this “done”. Let me know how you go!