Skip to content

Usage of LogBuffering is confusing #1042

@ogix

Description

@ogix

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.

Metadata

Metadata

Assignees

Labels

area/loggingCore logging utilityhelp wantedTasks you want help from anyone to move forward

Projects

Status

👀 In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions