Calming down EF Core logging

EF Core logging is awesome by default for debugging purposes. At info level you get every query and response going and coming from the db. Don't get me wrong this is great for development and debugging but can be a bit excessive when running an application in a production environment.

Here is a neat trick you can do when using Serilog (if you're using Serilog but really if not, you should be)

Add a small filter to keep calm the Microsoft tagged log events so that only Warning level log events are emiited to the Sinks.

I've put this into Configure in Startup.cs so that Serilog can configure logging levels per the ASPNETCORE_ENVIROMNET variable. With this we get nice rich logs in development enviroments and quiter logs in production environments.