I currently am working on a .NET 4.8 project deployed using an Azure pipeline. This project uses Serilog to write logs to a SQL database, and has been doing this for some time. The Serilog logic listed below:
//Initialize Logger
Log.Logger = new LoggerConfiguration()
.WriteTo.MSSqlServer(
connectionString: ConfigurationManager.ConnectionStrings["SerilogConnection"].ConnectionString,
sinkOptions: new MSSqlServerSinkOptions
{
TableName = "WEB_APIS_LOGS",
SchemaName = "dbo",
AutoCreateSqlTable = false
},
columnOptions: columnOpts
)
.CreateLogger();
How Serilog is being used:
Log.Logger.Write(logEventLevel, "{Entity}{EntityId}{@ValidationResult}", "SalesOrder", order.OrderId, order.Rules);
Last week I made a small change that doesn't effect any logging logic whatsoever, and after I deployed it via our Azure pipeline the logging no longer works. I tried reverting to an earlier release and that did nothing. I thought it may be because I changed the pipeline name around this time, but still no luck after reverting it back.
I enabled self logging for Serilog locally to see what popped up, and I got the error "The type initializer for 'Microsoft.Data.SqlClient.InOutOfProcHelper' threw an exception.". I am not sure if this is just a local issue or not, but it is the only clue I possibly have to what is wrong. I am able to connect to the database just fine and have not touched any project packages so I do not know why there would suddenly be issues after this specific release. This is the newest release in over a year so maybe that has something to do with it, but again no substantial changes were made to the code and none were made to the pipeline so I am completely lost.
Configuration: Web.config
<system.web>
<compilation debug="true" targetFramework="4.8" />
<httpRuntime targetFramework="4.6.1" />
</system.web>
Packages.config
<package id="Microsoft.Data.SqlClient" version="5.0.1" targetFramework="net48" />
I added a Serilog debugging log file to the server and got this error, so it turns out it is a certificate issue.
Unable to write 1 log events to the database due to following error: A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)