Skip to content

appSettings not read, Unable to find a method called MSSqlServer #656

@Xylotomous

Description

@Xylotomous

Hello, I was loathe to open an issue because I realize people are busy and I am a first-time user of this Sink. However, I was unable to source any solution or much information at all about this problem. I'll do my best to break it down with included information.

Serilog itself has been working for some months. There is both a Console sink and File sink in use. They both read properties from the appSettings without issue.

  1. Configured this sink and received an exception that tableName cannot be null. It is in the appSettings Serilog config in the right location.
  2. Configuring the name directly in code, the exception goes away and Serilog will use the Sink, applying the defaults only, and logging to Sql Server.
  3. Used Serilog Selflog and saw the message: Unable to find a method called MSSqlServer

I assume this is the cause of the problem. Further interesting case, but fairly similar. I want LogEvent and not Properties and so amended my table in Sql Server to have the desired column and dropped Properties. If I do the same as above, configuring sinkOptions -> TableName = "Logs" and add/remove the columns from the Store in code, it will also proceed to log to Sql Server correctly. Serilog Selflog will still report it can't find the method MSSqlServer.

I have a few config changes from the default I require and will probably proceed with defining it all in code directly (I'm assuming it will work) as this is a very featureful Sink and I'd like to use it, thank you for providing it to the community.

More details, hopefully helpful

The project is using .net 8.x runtime, and is an AspNetCore application using 8.x packages of such.

Serilog packages are:

Serilog.AspNetCore Version="8.0.1"
Serilog.Settings.Configuration Version="8.0.0"
Serilog.Sinks.Console Version="5.0.0"
Serilog.Sinks.File Version="5.0.0"
Serilog.Sinks.MSSqlServer Version="8.2.2"

I initially tried with the latest Serilog.Sinks.MSSqlServer Version="9.0.2" as well

Included is the config file section, excluding the other sinks for brevity

"Serilog": { "Using": [ "Serilog.Sinks.MSSqlServer" ], "MinimumLevel": { "Default": "Information", "Override": { "Microsoft": "Warning", "System": "Warning" } }, "Enrich": [ "FromLogContext" ], "WriteTo": [ { "Name": "MSSqlServer", "Args": { "sinkOptionsSection": { "tableName": "Logs", "batchPostingLimit": 1000 }, "restrictedToMinimumLevel": "Information", "columnOptionsSection": { "disableTriggers": true, "clusteredColumnstoreIndex": false, "primaryKeyColumnName": "Id", "addStandardColumns": [ "LogEvent" ], "removeStandardColumns": [ "Properties" ], "id": { "nonClusteredIndex": true }, "level": { "storeAsEnum": false }, "timeStamp": { "columnName": "Timestamp", "convertToUtc": true, "DataType": "datetimeoffset" }, "logEvent": { "excludeAdditionalProperties": true, "excludeStandardColumns": true } } } } ] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions