Skip to content

Feature request: Handle Exceptions and Prevent application from crashing when using Logger #514

Closed
@rahulpnath

Description

@rahulpnath

Use case

On exceptions within the Logging framework code, currently, it throws an exception and brings down the whole application.
For example below is a code that has a mismatch count of parameters passed to the log message - Missing Count property value being passed in.

Logger.LogInformation(extraKeys, "Retrieved data for city {cityName} with count {Count}", new[] { cityName });

It throws an exception and causes the Lambda Handler endpoint to crash and return a 500 Internal Server Error

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Microsoft.Extensions.Logging.LogValuesFormatter.GetValue(Object[] values, Int32 index)
   at Microsoft.Extensions.Logging.FormattedLogValues.get_Item(Int32 index)
   at Microsoft.Extensions.Logging.FormattedLogValues.GetEnumerator()+MoveNext(

Solution/User Experience

On exceptions within the logging framework, it should gracefully handle this without causing the application to crash. A similar approach is taken by other popular libraries in this space (e.g Serilog)

Alternative solutions

No response

Acknowledgment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/loggingCore logging utilityfeature-requestNew or enhancements to existing featuresstatus/confirmedThe scope is clear, ready for implementationtriagePending triage from maintainers

    Type

    No type

    Projects

    Status

    👀 In review

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions