Please clearly describe what the SQL Sink is doing incorrectly:
If you enable the AutoCreateSqlDatabase option and the DB already exists this sink will write an exception to the Serilog self log each time the application is started.
Please clearly describe the expected behavior:
No "create DB" action should be executed if the DB already exists.
If this is not possible, at least the "Database 'Xyz' already exists." exception should be handled and not logged.
List the names and versions of all Serilog packages used in the project:
Serilog: 3.0.1
Serilog.Sinks.MSSqlServer: 6.3.0
Serilog.AspNetCore: 7.0.0
Target framework and operating system:
.NET 7
OS: Windows 10
Provide a simple reproduction of your Serilog configuration code:
var builder = WebApplication.CreateBuilder(args);
// configure services ...
builder.Host.UseSerilog((context, services, loggerConfiguration) => loggerConfiguration
.ReadFrom.Configuration(context.Configuration));
var app = builder.Build();
// ...
Provide a simple reproduction of your Serilog configuration file, if any:
If you enable the
AutoCreateSqlDatabase
option and the DB already exists this sink will write an exception to the Serilog self log each time the application is started.No "create DB" action should be executed if the DB already exists. If this is not possible, at least the "Database 'Xyz' already exists." exception should be handled and not logged.
.NET 7 OS: Windows 10
Not required. The error is logged as soon as
builder.Build()
is called.