You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Format messages without quotes when log events come from Microsoft.Extensions.Logging
Also add the possibility to completely customize how the message is formatted with the new `Log4NetTextFormatterOptionsBuilder.UseMessageFormatter` method.
/// <item>If the log event comes from <c>Microsoft.Extensions.Logging</c> (detected by the presence of the <c>EventId</c> property) then the message is formatted by switching off quoting of strings.</item>
143
+
/// <item>If the log event comes from Serilog, then the message is formatted by calling <see cref="LogEvent.RenderMessage(System.IO.TextWriter,System.IFormatProvider)"/>.</item>
144
+
/// </list>
145
+
/// </summary>
146
+
/// <param name="logEvent">The log event to format.</param>
147
+
/// <param name="formatProvider">The <see cref="IFormatProvider"/> that supplies culture-specific formatting information, or <see langword="null"/>.</param>
Debugging.SelfLog.WriteLine($"[{GetType().FullName}] An exception was thrown while formatting a message. Using the default message formatter.\n{exception}");
@@ -136,6 +139,23 @@ public Log4NetTextFormatterOptionsBuilder UsePropertyFilter(PropertyFilter filte
136
139
returnthis;
137
140
}
138
141
142
+
/// <summary>
143
+
/// Sets the <see cref="MessageFormatter"/> controlling how all messages are formatted.
144
+
/// <para/>
145
+
/// The default message formatter has two formatting modes.
146
+
/// <list type="bullet">
147
+
/// <item>If the log event comes from <c>Microsoft.Extensions.Logging</c> (detected by the presence of the <c>EventId</c> property) then the message is formatted by switching off quoting of strings.</item>
148
+
/// <item>If the log event comes from Serilog, then the message is formatted by calling <see cref="LogEvent.RenderMessage(System.IO.TextWriter,System.IFormatProvider)"/>.</item>
149
+
/// </list>
150
+
/// </summary>
151
+
/// <remarks>If an exception is thrown while executing the formatter, the default formatter will be used.</remarks>
152
+
/// <returns>The builder in order to fluently chain all options.</returns>
/// <returns><see langword="true"/> to include the Serilog property in the log4net properties or <see langword="false"/> to ignore the Serilog property.</returns>
0 commit comments