Skip to content

Commit fb8faca

Browse files
committed
Refactor how exceptions are written
1 parent 3a3d9a8 commit fb8faca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Log4NetTextFormatter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private void WriteEvent(LogEvent logEvent, XmlWriter writer)
125125
WriteProperties(logEvent, writer, properties, machineNameProperty);
126126
}
127127
WriteMessage(logEvent, writer);
128-
WriteException(logEvent, writer, UsesLog4JCompatibility ? "throwable" : "exception");
128+
WriteException(logEvent, writer);
129129
writer.WriteEndElement();
130130
}
131131

@@ -358,10 +358,9 @@ private void WriteMessage(LogEvent logEvent, XmlWriter writer)
358358
/// </summary>
359359
/// <param name="logEvent">The log event.</param>
360360
/// <param name="writer">The XML writer.</param>
361-
/// <param name="elementName">The element name, should be either <c>exception</c> or <c>throwable</c>.</param>
362361
/// <remarks>https://github.com/apache/logging-log4net/blob/rel/2.0.8/src/Layout/XmlLayout.cs#L288-L295</remarks>
363362
[SuppressMessage("Microsoft.Design", "CA1031", Justification = "Protecting from user-provided code which might throw anything")]
364-
private void WriteException(LogEvent logEvent, XmlWriter writer, string elementName)
363+
private void WriteException(LogEvent logEvent, XmlWriter writer)
365364
{
366365
var exception = logEvent.Exception;
367366
if (exception == null)
@@ -380,6 +379,7 @@ private void WriteException(LogEvent logEvent, XmlWriter writer, string elementN
380379
}
381380
if (formattedException != null)
382381
{
382+
var elementName = UsesLog4JCompatibility ? "throwable" : "exception";
383383
WriteContent(writer, elementName, formattedException);
384384
}
385385
}

0 commit comments

Comments
 (0)