aws / aws/aws-logging-dotnet

Output errors to Serilog.SelfLog for exceptions

Open
#238 1 comment 1 reaction 0 assignees View on GitHub
feature-request module/logging p2 queued
Dominant language
C#
Stars
307
Forks
135
Avg merge
1d 10h
Merged PRs (30d)
4

Description

### Describe the feature

Serilog has a facility that allows components to report errors during operation. The AWS Serilog Sink should report errors to this SelfLog. https://github.com/serilog/serilog/wiki/Debugging-and-Diagnostics

### Use Case

Our application uses multiple sinks, for example a sqlserver sink, and errors from those sinks are logged in the Selflog. Our applications plugs in to the self log and will report itself as unhealthy if there are messages in the self log. We also record this logs for later inspection, and display it in a verbose healthcheck for the dev environment.

The AWSSerilog sink however only writes errors to a text file `aws-logger-errors.txt` for logging errors. However this file may never be created depending on the rights of the user account, for example in hardened

### Proposed Solution

`AWSLoggerCore` should expose a new optional constructor argument or a new constructor overload with an argument `Action onError`. If this is set, the `LogLibraryServiceError` method should invoke this delegate instead of creating the log file. AWSSink will then use this method write to the SelfLog.

```csharp
_core = new AWSLoggerCore(loggerConfiguration, "SeriLogger", m => Serilog.Debugging.SelfLog.WriteLine(m));
```

Creating an optional constructor argument will be a binary breaking change, but creating a new overload will not produce a breaking change.

### Other Information

_No response_

### Acknowledgements

- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### AWS .NET SDK and/or Package version used

AWS.Logger.SeriLog 3.3.0

### Targeted .NET Platform

.NET 6, .NET 8

### Operating System and version

Linux .NET docker containers

Contributor guide

Open the contributing guide

Research direction

Locate AWSLoggerCore, its LogLibraryServiceError method, and the AWSSink construction path. Read the existing error-handling flow and check how Serilog.Debugging.SelfLog.WriteLine can be passed through an overload. Done means sink exceptions reach SelfLog without requiring aws-logger-errors.txt, while existing construction remains compatible.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, csharp
Domain
observability-sre
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.