serilog / serilog-settings-configuration

A Serilog configuration provider that reads from Microsoft.Extensions.Configuration
Apache License 2.0
444 stars 129 forks source link

Reading value from another node? #410

Closed bakbuz closed 5 months ago

bakbuz commented 7 months ago

Hi guys

I have a tiny question. Can I read a value from another node?

Is it possible?

Example:

{
  "ConnectionStrings": {
    "MongoDB": "mongodb+srv://BLABLABLABLA"
  },
  "Serilog": {
    "MinimumLevel": {
      "Default": "Information",
      "Override": {
        "Microsoft": "Error",
        "System": "Warning"
      }
    },
    "Enrich": [ "FromLogContext" ],
    "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.MongoDB" ],
    "WriteTo": [
      {
        "Name": "Console"
      },
      {
        "Name": "MongoDB",
        "Args": {
          "databaseUrl": "ConnectionStrings:MongoDB",
          "collectionName": "system_logs",
          "cappedMaxSizeMb": "1024",
          "cappedMaxDocuments": "50000",
          "rollingInterval": "Month"
        }
      }
    ]
  }
}

Look at this line: "databaseUrl": "ConnectionStrings:MongoDB",

nblumhardt commented 7 months ago

Hi! No, that isn't possible currently - it's not likely we'd support it directly here in Serilog, but you might find some other options if you dig around in Microsoft.Extensions.Configuration. HTH!