newrelic / newrelic-dotnet-agent

The New Relic .NET language agent.
Apache License 2.0
95 stars 57 forks source link

Log4net to Serilog: Implement "In-Memory" Serilog Sink #1427

Closed tippmar-nr closed 1 year ago

tippmar-nr commented 1 year ago

Describe the story, please be clear on scope of the story.

At Agent startup, prior to the call to LoggerBootstrapper.Configure(), we need to capture log messages in memory, which will then be captured and propagated to the "real" logger that gets created in .Configure().

A NuGet package called Serilog.Sinks.InMemory exists, but only targets netstandard20. So we need to either implement our own simple in-memory sink or potentially fork the code for the Serilog.Sinks.InMemory package and modify it to support netframework462 as well as netstandard20. Note that the existing package was really designed for use in unit test scenarios, so contains much more functionality than we really need -- the only part we really need is the InMemorySink object and it's LogEvents property, so it may be easier to just copy the code directly into the Core project and give proper attribution to the author.

Potentially helpful URLs: https://github.com/serilog/serilog/wiki/Developing-a-sink https://github.com/serilog-contrib/SerilogSinksInMemory

After implementing the in-memory sink, modify the logger configuration in LoggerBootstrapper.Initialize() to configure the logger to use that sink. Then add code in LoggerBootstrapper.Configure() to extract log messages captured by the in-memory sink and echo them to the "real" logger.

Acceptance Criteria

Messages logged at startup, prior to calling LoggerBootstrapper.Configure() should be captured in the agent logfile.

Estimates

Please provide initial t-shirt size M

workato-integration[bot] commented 1 year ago

https://issues.newrelic.com/browse/NEWRELIC-7406

workato-integration[bot] commented 1 year ago

Work has been completed on this issue.