Skip to content

Serilog:Using Check Seems Unnecessarily Restrictive #389

@chrisoverzero

Description

@chrisoverzero

For an AOT-published application on .NET 8, I have the following configuration (in the Microsoft.Extensions.Configuration sense):

{
  "Serilog": {
    "MinimumLevel": "Debug"
  }
}

…and the rest of the Serilog configuration is done in C# code. I would like be able to change this log level at runtime. However, Serilog.Settings.Configuration fails at runtime when the only assembly to search is "Serilog". Because of how that is done, the following expected workarounds do not solve the problem:

{
  "Serilog": {
    "Using": [],
    "MinimumLevel": "Debug"
  }
}
{
  "Serilog": {
    "Using": null,
    "MinimumLevel": "Debug"
  }
}
{
  "Serilog": {
    "Using": ["Serilog"],
    "MinimumLevel": "Debug"
  }
}

All of which fail at runtime with the same error message: "No Serilog:Using configuration section is defined and no Serilog assemblies were found. This is most likely because the application is published as single-file." and so on.

In order to continue testing AOT publication, I have to configure like this:

{
  "Serilog": {
    "Using": ["<name of entry assembly>"],
    "MinimumLevel": "Debug"
  }
}

…but this is undesirable since we'd have to put the name of the entry assembly in the configuration for each application. Is there or can there be a way to give Serilog.Settings.Configuration a positive signal that the single assembly it found is OK?

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