I upgraded to .net core 2.2 and EF 2.2 as well. Now when i fetch a table from DbSet, for each row i have in my table there a log line and it's taking forever. How to disable this since i didnt have this logs in .net core 2.0 ?
ex : for the log line i have this for each row :
[15:58:02 DBG] Context 'BookContext' started tracking 'Book' entity.
Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see key values.
And since my table has 23000 records, i have 23000 log line as well !
My serilog log config looks like this :
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Debug"
}
},
you can make like this
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft.EntityFrameworkCore.Database.Command": "Error",
"Microsoft": "Debug",
}
},
I use below config in my appsettings.json. #Khaled's answer was having wrong level of json format. Thank you it helps.
I hope this will help someone who end up on this thread.
My config was like below:
"Serilog": {
"Using": [ "Serilog.Sinks.MSSqlServer" ],
"MinimumLevel": "Debug",
"Override": {
"Microsoft.EntityFrameworkCore.Database.Command": "Error",
"Microsoft": "Debug"
},
Related
I have two applications(one from Host and other from WebHost). Both .NET 6. I have multiple Serilog sinks as below in both apps configured in appsettings.json(its a valid json). I'm trying to use dictionary mode of configuring sinks in WriteTo section instead of array(see https://github.com/serilog/serilog-settings-configuration#writeto-enrich-auditto-destructure-sections).
In WebHost application appsettings are loaded without a problem.
But in Host application I get this error "The configuration value in Serilog:WriteTo:0:Name has no 'Name' element."
inside IHostBuilder.UseSerilog(...).
What am I getting wrong here?
I have checked with another WebHost application and it works. None of the Host applications are working.
"Serilog": {
"MinimumLevel": {
"Default": "Information"
},
"WriteTo": {
"FileSink": {
"Name": "File",
"Args": {
...
}
},
"ConsoleSink": {
"Name": "Console",
"Args": {
...
}
}
}
}
},
Hi Today I added a SSL certificate for a ASP.NET website.
After adding the certificate I am getting ERR_HTTP2_INADEQUATE_TRANSPORT_SECURITY error
If I access site using http its working but https its giving the error
[Application hosted in Windows server 2016 and IIS 10]
You can try to disable HTTP2 and try it again:
Start → regeditEditor
Navigate to the folder/path: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters
Under the Parameters folder, right-click the white-space, add 2 new
DWORD (32-bit) values:
EnableHttp2Tls
EnableHttp2Cleartext
Ensure both new values have been set to 0(disabled) by
right-clicking the value and clicking "Modify..."
Restart the OS.
You can configure Kestrel server to serve Http1. Please follow the following instruction to solve the problem -
Go to your project appsettings.json file.
Add below code under "AllowedHosts": "*" line
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http1"
}
}
Your default appsettings.json file will look like this -
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http1"
}
}
}
Hope it will solve your problem.
I have developed a web application in .Net Core 3.1 (Web API) using Entity Framework 3.1, Angular 10.0 and SQL Server as database.
I have followed code first approach and everything was fine until I deployed my app to IIS on a virtual machine. When I am trying to login to my app for the first time noticed the below error response in the chrome developer console while connecting with my database -
AppSettings.json -
{
"AppSettings" : {
"Token" : "******"
},
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=datingapp;User Id=appuser;Password=*****"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
}
UPDATE : Similar error from postman as well.
Please advise what is wrong with my connection string or could it be something else ?
Thank you
I'm trying to follow a tutorial on adding an Azure Cognitive Search service to my .NET Core app, and don't want to mess anything up. The tutorial says to add the following to my appsettings.json file:
{
"SearchServiceName": "<placeholder-Azure-Search-service-name>",
"SearchServiceAdminApiKey": "<placeholder-admin-key-for-Azure-Search>",
"AzureSqlConnectionString": "<placeholder-ADO.NET-connection-string",
}
Problem is, my appsettings.json file already has stuff in it:
{
"ConnectionStrings": {
"DefaultConnection": "Data Source=xxx.database.windows.net,1433;Initial Catalog=XChange;Persist Security Info=False;User ID=xxx;Password=xxx;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
When I try to add the Azure API call at the bottom it says only one top-level item is allowed, and if I assign some key to it inside the top-level json object I'm afraid the API won't work -- I don't use JSON very much and I'm new to .NET so sorry if this is a stupid question, I couldn't find any docs explaining what to do
It means your JSON is incorrect , you need to have it in the form of object with a key. Do something like
{
"ConnectionStrings": {
"DefaultConnection": "Data Source=xxx.database.windows.net,1433;Initial Catalog=XChange;Persist Security Info=False;User ID=xxx;Password=xxx;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Configuration": {
"SearchServiceName": "<placeholder-Azure-Search-service-name>",
"SearchServiceAdminApiKey": "<placeholder-admin-key-for-Azure-Search>",
"AzureSqlConnectionString": "<placeholder-ADO.NET-connection-string"
}
}
The default project template has the following logging configuration in appSettings.json:
"Logging": {
"IncludeScopes": true,
"LogLevel":
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
What are Default, System and Microsoft for?
Both the System and Microsoft namespace assemblies have a logging level that is honored. Consider an MVC 6 application, imagine in your project.json that you have a dependency of "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final" - this assembly is prefixed with "Microsoft". Internally its logging will be output with the level specified in your config.
Likewise, in your application "Default" is relevant to your application. Consider the following:
void FooBar(ILogger logger)
{
logger.LogCritical("LoglLevel.Critical");
logger.LogDebug("LoglLevel.Debug");
logger.LogError("LoglLevel.Errror");
logger.LogInformation("LoglLevel.Information");
logger.LogTrace("LoglLevel.Trace"); // This message would not be written
logger.LogWarning("LoglLevel.Warning");
}
// This is the severity
public enum LogLevel
{
Trace,
Debug,
Information,
Warning,
Error,
Critical,
None
}
So if you set "Microsoft": "Critical" and internally MVC encounters and logs an exception via the logger.LogError method, it will not be written in the output of the log.