Closed
Description
Please clearly describe what the SQL Sink is doing incorrectly:
.Net 8.0 API build correctly but when trying to debug in visual studio (F5) this is the exception:
CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')
en-us is an invalid culture identifier.
Please clearly describe the expected behavior:
Have logs saved in database table
List the names and versions of all Serilog packages used in the project:
- Serilog.AspNetCore: 8.0.0
- Serilog.Settings.Configuration: 8.0.0
- Serilog.Sinks.MSSqlServer: 6.5.0
- Serilog.Sinks.Console: 5.0.1
- Serilog.Sinks.File: 5.0.0
Target framework and operating system:
.NET 8
OS: Windows
Provide a simple reproduction of your Serilog configuration code:
appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.MSSqlServer", "Serilog.Sinks.File" ],
"MinimumLevel": "Information",
"WriteTo": [
{
"Name": "Console"
},
{
"Name": "File",
"Args": {
"path": ".\\Logs\\LogEvents-.txt",
"rollingInterval": "Day",
"rollOnFileSizeLimit": true
}
},
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "myConnectionString",
"sinkOptionsSection": {
"tableName": "LogEvents",
"batchPostingLimit": 100,
"period": "0.00:00:10"
},
"restrictedToMinimumLevel": "Warning"
}
}
]
},
"AllowedHosts": "*",
"ConnectionStrings": {
"cnSql": "myConnectionString"
}
}
Provide a simple reproduction of your application code:
Program.cs
using Serilog;
var builder = WebApplication.CreateBuilder(args);
//Add support to logging with SERILOG
builder.Host.UseSerilog((context, configuration) => configuration.ReadFrom.Configuration(context.Configuration));
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
app.UseHttpsRedirection();
//Add support to logging request with SERILOG
app.UseSerilogRequestLogging();
app.UseAuthorization();
app.MapControllers();
app.Run();
Metadata
Metadata
Assignees
Labels
No labels