App.config looks like this:
<appender name="MemoryAppender" type="log4net.Appender.MemoryAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level - %message" />
</layout>
</appender>
Code looks like this:
foreach (var ev in events)
{
string msg = ev.RenderedMessage;
}
The string returned from ev.RenderedMessage
is just the message, not the entire pattern. I've also tried using WriteRenderedMessage
with a StringWriter
and the result was the same. Is there a way to get the message with the pattern applied?
I found it :)
var events = _ma.GetEvents();
string result = "";
using (StringWriter writer = new StringWriter())
{
foreach (var ev in events)
{
_ma.Layout.Format(writer, ev);
writer.Write(Environment.NewLine);
}
result = writer.ToString();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With