When using Kestrel in an ASP.NET Core 2.1 project and specifying a binding in UseKestrel()
, a message is logged at warning level:
Overriding address(es) 'http://localhost:50000/'. Binding to endpoints defined in UseKestrel() instead.
This adds noise to our logs, reports a default (and therefore confusing) URL, and shouldn't be a warning. Short of filtering the message by the logger itself, is there a way to configure the web host builder so it doesn't log this on startup?
First of all, that “noise” is not really that noise if you consider that you only get this once when the application starts. So unless you are doing something weird where you need to restart your app, then you will probably almost never see that line in your logs, compared to all those other (much noisier) messages.
That being said, it is actually a useful warning because it tells you that you have configured the binding URL in multiple locations. So the proper action is not to ignore that message but to actually remove the duplicate configurations.
In this case, you are using explicit listen options with UseKestrel()
so that trumps everything. So you should remove the other configurations. There are a few locations where you should look:
ASPNETCORE_URLS
environment variable.ASPNETCORE_SERVER.URLS
environment variable.Properties/launchSettings.json
.