powertools-lambda-dotnet icon indicating copy to clipboard operation
powertools-lambda-dotnet copied to clipboard

Usage of LogBuffering is confusing

Open ogix opened this issue 2 months ago • 2 comments

I was surprised to find out that currently log buffering (and their default options) is only enabled when LogBuffering in PowertoolsLoggerConfiguration is not null:

https://github.com/aws-powertools/powertools-lambda-dotnet/blob/eb62bf4ce7e0c1d63f0828ec07497d04eea596b5/libraries/src/AWS.Lambda.Powertools.Logging/PowertoolsLoggingBuilderExtensions.cs#L191C1-L192C1

This can be confusing as some would expect that LogBufferingOptions is only used when you want to override some default options (common practice).

For example now if you want to enabled buffering and don't want to override default options - you need to instantiate empty options object (looks a bit weird): Logger.Configure(options => options.LogBuffering = new LogBufferingOptions());

What other libraries (for example Microsoft) do instead - all Options are instantiated by default and you just override properties instead: Logger.Configure(options => options.LogBuffering.Enabled = true);

Consider also introducing Enabled property to avoid confusion and NRE's.

ogix avatar Oct 16 '25 10:10 ogix

Thanks for opening your first issue here! We'll come back to you as soon as we can. In the meantime, check out the #dotnet channel on our Powertools for AWS Lambda Discord: Invite link

boring-cyborg[bot] avatar Oct 16 '25 10:10 boring-cyborg[bot]

Hi @ogix thank you for raising the issue. I really appreciate taking the time to suggest improvements.to Powertools. I do see your point and we will be putting this in the backlog to be implemented.

hjgraca avatar Oct 16 '25 11:10 hjgraca