Skip to content

Commit 62d29d7

Browse files
committed
Use XmlConvert.ToString for converting log4j milliseconds to string
1 parent 253e9a0 commit 62d29d7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/Log4NetTextFormatter.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics.CodeAnalysis;
4-
using System.Globalization;
54
using System.IO;
65
using System.Linq;
76
using System.Xml;
@@ -100,7 +99,7 @@ private void WriteEvent(LogEvent logEvent, XmlWriter writer)
10099
var useLog4JCompatibility = _options.Log4NetXmlNamespace?.Name == "log4j";
101100
WriteStartElement(writer, "event");
102101
WriteEventAttribute(logEvent, writer, "logger", Constants.SourceContextPropertyName);
103-
var timestamp = useLog4JCompatibility ? logEvent.Timestamp.ToUnixTimeMilliseconds().ToString(CultureInfo.InvariantCulture) : XmlConvert.ToString(logEvent.Timestamp);
102+
var timestamp = useLog4JCompatibility ? XmlConvert.ToString(logEvent.Timestamp.ToUnixTimeMilliseconds()) : XmlConvert.ToString(logEvent.Timestamp);
104103
writer.WriteAttributeString("timestamp", timestamp);
105104
writer.WriteAttributeString("level", LogLevel(logEvent.Level));
106105
WriteEventAttribute(logEvent, writer, "thread", ThreadIdPropertyName);

0 commit comments

Comments
 (0)