Is there a way to log the client Ips ?
Hi @cristipufu I wanted to log the IPs that are requesting data for testing purpose, can we do that ?
Not sure if this question is related to AspNetCoreRateLimit, but you can always create your own custom middleware to log the IPs, similar to this example: https://docs.microsoft.com/en-us/aspnet/core/security/ip-safelist?view=aspnetcore-3.1
@ashamandava and @cristipufu
This may not be exactly what you are looking for but if you are using Application Insights you can have it listen for the ILogger Information messages from the rate-limiting middleware. This can be done through appsettings.json.
e.g.
"Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" }, "ApplicationInsights": { "LogLevel": { "Default": "Warning", "AspNetCoreRateLimit": "Information" } } }
In this example, we are telling Application Insights to record Warning (and above), except for when it comes to AspNetCoreRateLimit where we record Information (and above).
This lets you see the failure in Application Insights with a trace explaining why the request was blocked. I.e. what rule was applied.