Skip to content

Output errors to Serilog.SelfLog for exceptions #238

Open
@almostchristian

Description

@almostchristian

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<string> 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.

_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

  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions