.Net Core Serilog MSSQLServer Sink addAdditionalColumns to existing table

77 views Asked by At

I'm trying to add some new columns to my existing log. It only works if I remove the table completely and it generates a new one for me with all the columns.. If I try to tack on some new columns in the json configuration. It doesn't create it. See below. SourceId is the new column. Is there some additional configuration I need to set so it updates the table when new columns are added?


{
  "Serilog:WriteTo:0:Args:configureLogger": {
    "Filter": [
      {
        "Name": "ByIncludingOnly",
        "Args": {
          "expression": "RequestPath like '/mypath%'"
        }
      }
    ],
    "WriteTo": [
      {
        "Name": "MSSqlServer",
        "Args": {
          "connectionString": "LoggingConnection",
          "tableName": "MyTable",
          "schemaName": "dbo",
          "autoCreateSqlTable": true,
          "batchPostingLimit": 150,
          "period": "0.00:00:30",
          "columnOptionsSection": {
            "addStandardColumns": [ "LogEvent" ],
            "removeStandardColumns": [ "MessageTemplate" ],
            "timeStamp": {
              "columnName": "EventDate",
              "convertToUtc": true
            },
            "additionalColumns": [
              {
                "ColumnName": "MachineName",
                "DataType": "nvarchar",
                "DataLength": 128,
                "AllowNull": false
              },
              {
                "ColumnName": "ProcessId",
                "DataType": "int",
                "AllowNull": false
              },
              {
                "ColumnName": "ThreadId",
                "DataType": "int",
                "AllowNull": false
              },
              {
                "ColumnName": "RequestPath",
                "DataType": "nvarchar",
                "DataLength": -1
              },
              {
                "ColumnName": "SourceId",
                "DataType": "int",
                "AllowNull": false
              }
            ]
          }
        }
      }
    ]
  }
}

Tried to existing table and fails Tried with no table. Generates new table and succeeds. I expect it to create the new columns when I run the app.

0

There are 0 answers