Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
rahulpnath opened this issue Nov 14, 2023 · 1 comment · Fixed by #538
Closed
2 tasks done
Labels
area/logging Core logging utility feature-request New or enhancements to existing features status/confirmed The scope is clear, ready for implementation triage Pending triage from maintainers

Comments

@rahulpnath
Copy link

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

@rahulpnath rahulpnath added feature-request New or enhancements to existing features triage Pending triage from maintainers labels Nov 14, 2023
Copy link

boring-cyborg bot commented Nov 14, 2023

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

@rahulpnath rahulpnath changed the title Feature request: Handle Exceptions and Prevent application crashing Feature request: Handle Exceptions and Prevent application from crashing Nov 14, 2023
@rahulpnath rahulpnath changed the title Feature request: Handle Exceptions and Prevent application from crashing Feature request: Handle Exceptions and Prevent application from crashing when using Logger Nov 14, 2023
@hjgraca hjgraca moved this to 📋 Backlog in Powertools for AWS Lambda (.NET) Nov 15, 2023
@hjgraca hjgraca added area/logging Core logging utility logging status/confirmed The scope is clear, ready for implementation labels Nov 15, 2023
@hjgraca hjgraca moved this from 📋 Backlog to 🏗 In progress in Powertools for AWS Lambda (.NET) Jan 5, 2024
@hjgraca hjgraca moved this from 🏗 In progress to 👀 In review in Powertools for AWS Lambda (.NET) Jan 5, 2024
@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label Feb 16, 2024
@hjgraca hjgraca removed the pending-release Fix or implementation already in dev waiting to be released label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/logging Core logging utility feature-request New or enhancements to existing features status/confirmed The scope is clear, ready for implementation triage Pending triage from maintainers
Projects
Status: 👀 In review
2 participants