The v3.3.1 fix for #22 was incomplete. #22 reported two defects in the generic AddJsonFile<TProvider>: (a) ConfigureTextBuilder ignoring optionsName, and (b) the user configure callback being registered against Options.DefaultName instead of the provider's named-options instance. The fix (commit fe6a9fe) addressed (a) only; (b) is still present in v4.1.0.
Where: source/FileLogger.Json/JsonFileLoggerExtensions.cs. Every generic overload (<TProvider>, <TProvider,TOptions>, and the bindOptions variant) calls builder.AddFile<…>(context, configure: null, optionsName) and then builder.Services.Configure(configure) — unnamed, so it binds to Options.DefaultName. The provider reads its options under optionsName ?? typeof(TProvider).ToString(), so the configure callback never reaches it. Within a single call, TextBuilder lands on the named instance while the user's configure lands on DefaultName.
Scope: this fires whenever configure is supplied — an explicit optionsName is not required, since the provider reads under typeof(TProvider).ToString(), never DefaultName.
Contrast: the sibling AddFile<TProvider> in FileLoggerFactoryExtensions.cs is correct — builder.Services.Configure(optionsName, configure).
Repro:
loggingBuilder.AddJsonFile<MyFileLoggerProvider>(
optionsName: "MyJson",
configure: o => o.RootPath = AppContext.BaseDirectory);
The resulting provider does not see RootPath — it reads options "MyJson", but configure was applied to "".
Suggested fix: forward configure into AddFile<TProvider>(context, configure, optionsName), which already names it, and drop the trailing unnamed Services.Configure. Equivalent: builder.Services.Configure(optionsName ?? typeof(TProvider).ToString(), configure).
Workaround (per #22): omit configure: and call Services.Configure<FileLoggerOptions>(optionsName, …) separately.
Version: 4.1.0. Related: #22 (original report, closed as fixed in v3.3.1).
The v3.3.1 fix for #22 was incomplete. #22 reported two defects in the generic
AddJsonFile<TProvider>: (a)ConfigureTextBuilderignoringoptionsName, and (b) the userconfigurecallback being registered againstOptions.DefaultNameinstead of the provider's named-options instance. The fix (commitfe6a9fe) addressed (a) only; (b) is still present in v4.1.0.Where:
source/FileLogger.Json/JsonFileLoggerExtensions.cs. Every generic overload (<TProvider>,<TProvider,TOptions>, and thebindOptionsvariant) callsbuilder.AddFile<…>(context, configure: null, optionsName)and thenbuilder.Services.Configure(configure)— unnamed, so it binds toOptions.DefaultName. The provider reads its options underoptionsName ?? typeof(TProvider).ToString(), so theconfigurecallback never reaches it. Within a single call,TextBuilderlands on the named instance while the user'sconfigurelands onDefaultName.Scope: this fires whenever
configureis supplied — an explicitoptionsNameis not required, since the provider reads undertypeof(TProvider).ToString(), neverDefaultName.Contrast: the sibling
AddFile<TProvider>inFileLoggerFactoryExtensions.csis correct —builder.Services.Configure(optionsName, configure).Repro:
The resulting provider does not see
RootPath— it reads options"MyJson", butconfigurewas applied to"".Suggested fix: forward
configureintoAddFile<TProvider>(context, configure, optionsName), which already names it, and drop the trailing unnamedServices.Configure. Equivalent:builder.Services.Configure(optionsName ?? typeof(TProvider).ToString(), configure).Workaround (per #22): omit
configure:and callServices.Configure<FileLoggerOptions>(optionsName, …)separately.Version: 4.1.0. Related: #22 (original report, closed as fixed in v3.3.1).