Skip to content

ILoggerProvider implementation - does not read the config settings #93562

Open
@DavidThielen

Description

@DavidThielen

Description

I have one ILoggerProvider that works perfectly (in Blazor server). The other does not get the configuration settings.

Even weirder, if you define the [Blob] provider to be passed FileLoggerOptions, it then gets the File options, event though it's defined with [ProviderAlias("Blob")]

Reproduction Steps

I have a very simple example here.

Set a breakpoint on the constructors. You will see that BlobLoggerOptions is not populated:

		public BlobLoggerProvider(IOptionsMonitor<BlobLoggerOptions> options) : this(options.CurrentValue)
		{
			SettingsChangeToken = options.OnChange(opt => { Options = opt; });
		}

		public BlobLoggerProvider(BlobLoggerOptions options)
		{
			Options = options;
			Options = new BlobLoggerOptions
			{
				Path = "log/{yyyy-MM-dd}.txt",
				Interval = "day",
				AzureStorage = "UseDevelopmentStorage=true"
			};
			Interval = GetInterval(Options.Interval);

			Start();
		}

Set breakpoints in the constructors for FileLoggerProvider and you will see that FileLoggerOptions is populated.

Please note (maybe I shouldn't have done this), the BlobLoggerProvider constructor sets explicit values for the options. I have that so the logger can run - but that is there because the passed in options parameter has all null values. It should not be necessary to set these explicit values.

So there's some bug in when the appsettings.json file settings are populated in the options.

In addition (let me know if this is connected or if I need to create a 2nd bug report) - neither Dispose() not AsyncDispose() is called when the application ends.

Expected behavior

BlobLoggerOptions is populated when passed to the BlobLoggerProvider() constructor.

Actual behavior

BlobLoggerOptions is all nulls.

Regression?

No response

Known Workarounds

Hard code the properties in the code (not a good solution).

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions