Skip to content

Commit 9959247

Browse files
committed
Add test for logger name
1 parent 5d9c829 commit 9959247

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<log4net:event logger="Namespace.Component.Class" timestamp="2003-01-04T15:09:26.535+01:00" level="INFO" xmlns:log4net="http://logging.apache.org/log4net/schemas/log4net-events-1.2/">
2+
<log4net:message><![CDATA[Hello from Serilog]]></log4net:message>
3+
</log4net:event>

tests/Log4NetTextFormatterTest.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using ApprovalTests.Namers;
88
using ApprovalTests.Reporters;
99
using FluentAssertions;
10+
using Serilog.Core;
1011
using Serilog.Enrichers;
1112
using Serilog.Events;
1213
using Serilog.Parsing;
@@ -227,6 +228,21 @@ public void NullProperty()
227228
Approvals.VerifyWithExtension(output.ToString(), "xml");
228229
}
229230

231+
[Fact]
232+
public void LoggerName()
233+
{
234+
// Arrange
235+
using var output = new StringWriter();
236+
var logEvent = CreateLogEvent(properties: new LogEventProperty(Constants.SourceContextPropertyName, new ScalarValue("Namespace.Component.Class")));
237+
var formatter = new Log4NetTextFormatter();
238+
239+
// Act
240+
formatter.Format(logEvent, output);
241+
242+
// Assert
243+
Approvals.VerifyWithExtension(output.ToString(), "xml");
244+
}
245+
230246
[Fact]
231247
public void DefaultFormatProvider()
232248
{

0 commit comments

Comments
 (0)