serilog-settings-configuration icon indicating copy to clipboard operation
serilog-settings-configuration copied to clipboard

Configure ResourceAttributes via appsettings.json

Open steverb38 opened this issue 1 year ago • 4 comments

Hi,

Any suggestions on how to specifiy ResourceAttributes when configuring the sink via appsettings.json? Specifying Endpoint and Protocol in appsettings.json works fine, but I can't get the syntax for specifying the Dictionary<string, object> for ResourceAttributes:

This is my attempt in appsettings.json - the service.name attribute doesn't end up as "myapp-test", but some default value "unknown_service:...":

   "WriteTo": [
      {
        "Name": "OpenTelemetry",
        "Args": {
          "endpoint": "http://MyOtelCollectorServer:4318/v1/logs",
          "protocol": "HttpProtobuf",
          "resourceAttributes": {
			"service.name" : "myapp-test"
		   }
		}
          }
    ],

Is this even possible?

Steve

steverb38 avatar Sep 12 '23 17:09 steverb38