Net Core 6.0 and Serilog: problem with configuration

Please don't post links to code or the like. Apart from the inconvenience, if those links are broken for any reason then the thread becomes all but useless. Post the relevant code, error messages, etc, directly into the thread, formatted appropriately.
 
Please don't post links to code or the like. Apart from the inconvenience, if those links are broken for any reason then the thread becomes all but useless. Post the relevant code, error messages, etc, directly into the thread, formatted appropriately.

I'm really sorry for the inconvenience.
appsettings.json:
{
  "ConnectionStrings": {
    "SqlServer": "Server=127.0.0.1,1433;Database=MyDb;User ID=MyUser;Password=MyPass;MultipleActiveResultSets=true;Max Pool Size=500;Persist Security Info=True;Encrypt=False;TrustServerCertificate=False;"
  },
  "AppSettings": {
  },
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "Serilog": {
    "MinimumLevel": "Debug",
    "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId", "WithExceptionDetails" ],
    "WriteTo": [
      {
        "Name": "MSSqlServer",
        "Args": {
          "connectionString": "Server=127.0.0.1,1433;Database=MyDb;User ID=MyUser;Password=MyPass;MultipleActiveResultSets=true;Max Pool Size=500;Persist Security Info=True;Encrypt=False;TrustServerCertificate=False;"
          "restrictedToMinimumLevel": "Information",
          "sinkOptionsSection": {
            "tableName": "Serilog",
            "schemaName": "dbo",
            "autoCreateSqlTable": false,
            "batchPostingLimit": 100
          },
          "columnOptionsSection": {
            "removeStandardColumns": [ "MessageTemplate" ],
            "additionalColumns": [
              {
                "ColumnName": "ApplicationName",
                "DataType": "nvarchar",
                "DataLength": 200,
                "AllowNull": true
              }
            ]
          }
        }
      }
    ],
    "Properties": {
      "ApplicationName": "SampleName"
    }
  },
  "AllowedHosts": "*"
}
 
And here's a perfect example of why not to post links. Your link to your Program.cs is now dead, so we have no idea how you are loading/initializing SeriLog.
 
And here's a perfect example of why not to post links. Your link to your Program.cs is now dead, so we have no idea how you are loading/initializing SeriLog.

I have just found the problem. It wasn't on Pogram.cs but in the connection string for Serilog: the port number does not have to be specified.
 
Interesting... So I wonder how they will support MSSQL instances that do not use the default port number as a security defense in depth measure.
 
Interesting... So I wonder how they will support MSSQL instances that do not use the default port number as a security defense in depth measure.

It could be that the error only occurs using the default port.
I can't verify this because I don't have instances using other ports.
 
Perhaps serilog uses a different SQL driver that doesn't support some aspect of the connection string as presented
 
Perhaps serilog uses a different SQL driver that doesn't support some aspect of the connection string as presented

This SQL Server Driver uses 'Microsoft.Data.SqlClient' .

I think connection strings should be compatible with same platforms
 

Latest posts

Back
Top Bottom