Allows to configure Log4net as Microsoft Extensions Logging handler on any ASP.NET Core application. Original code proposal by @anuraj --> https://dotnetthoughts.net/how-to-use-log4net-with-aspnetcore-for-logging/
.NET 5 added a JSON Console Provider to the default log providers that can print structured logs in JSON [0].
It prints the state of the log messages (the formatting information) as special JSON values inside a state object, which makes it easy to query components of the message with JSON tooling:
In reality it's not even a full provider, but just a formatter for the generic console provider included by Microsoft [1].
The problem is: I'm not using the generic console provider, but this library to connect to Log4Net instead (great library btw 😄).
This also allows me to format messages as I like inside the Log4Net pipeline (e. g. with an ILayout implementation), but I can't access the state of the log messages in this step, because it is never provided to the Log4Net pipeline - only the formatted message is.
Because of this I wanted to ask if providing this state to Log4Net would be in the scope of this library and something that you would consider as a feature / PR.
For example with a configurable interface implementation that converts the MassageCandidate into the MessageObject passed to Log4Net, which can be overriden to include the state (or anything else one might need).
The default implementation would obviously replicate the current behaviour.
Hi,
.NET 5 added a JSON Console Provider to the default log providers that can print structured logs in JSON [0]. It prints the state of the log messages (the formatting information) as special JSON values inside a state object, which makes it easy to query components of the message with JSON tooling:
Outputs:
In reality it's not even a full provider, but just a formatter for the generic console provider included by Microsoft [1].
The problem is: I'm not using the generic console provider, but this library to connect to Log4Net instead (great library btw 😄). This also allows me to format messages as I like inside the Log4Net pipeline (e. g. with an ILayout implementation), but I can't access the state of the log messages in this step, because it is never provided to the Log4Net pipeline - only the formatted message is. Because of this I wanted to ask if providing this state to Log4Net would be in the scope of this library and something that you would consider as a feature / PR. For example with a configurable interface implementation that converts the MassageCandidate into the MessageObject passed to Log4Net, which can be overriden to include the state (or anything else one might need). The default implementation would obviously replicate the current behaviour.
Cheers
[0] https://docs.microsoft.com/en-gb/dotnet/core/extensions/console-log-formatter#json [1] https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Logging.Console/src/JsonConsoleFormatter.cs