How do I turn off the default logging done by ASP.NET and Entity Framework for each request?
I couldn't find yet how I can turn this logging off. I Use Asp.NET Core 3.1 and Serilog.Extensions.Logging.File
I am getting the multiple entity framework logs like Executed DbCommand and much more. When I run the project and close then it can generate 1000+ lines log. This is my log file.
2021-05-18T15:05:00.3079413+05:30 80000004-0000-e500-b63f-84710c7967bb [INF] Request finished in 2474.1038ms 200 application/json; charset=utf-8 (791a596a)
2021-05-18T15:05:00.3157337+05:30 80000008-0000-f100-b63f-84710c7967bb [INF] Executed DbCommand ("73"ms) [Parameters=[""], CommandType='Text', CommandTimeout='30']"
""SELECT TOP(1) [h].[HeaderCurrencyBarID], [h].[EURBuy], [h].[EURSell], [h].[ModifiedOn], [h].[USDBuy], [h].[USDSell]
FROM [HeaderCurrencyBar] AS [h]
ORDER BY [h].[ModifiedOn] DESC, [h].[HeaderCurrencyBarID] DESC" (0723d8ff)
This is my Configure method in the Program class:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.ConfigureLogging((hostingContext, logging) =>
{
logging.ClearProviders();
logging.AddConfiguration((IConfiguration)hostingContext.Configuration.GetSection("Logging"));
logging.AddFile("Logs/log.txt", retainedFileCountLimit: 31);
});
This is my appsettting.json file
"Logging": {
"LogLevel": {
"Default": "None",
"Microsoft": "None",
"Microsoft.Hosting.Lifetime": "None"
}
},
I want to delete 1 month's older log files automatically. I already setup in this project but it is not working.
I attached sample project here.