Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update XmlLayoutSchemaLog4j.cs #18

Merged
merged 1 commit into from
Oct 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Layout/XmlLayoutSchemaLog4j.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ override protected void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
}

// Write the start element
writer.WriteStartElement("log4j:event");
writer.WriteStartElement("log4j", "event", "log4net");
writer.WriteAttributeString("logger", loggingEvent.LoggerName);

// Calculate the timestamp as the number of milliseconds since january 1970
Expand All @@ -187,7 +187,7 @@ override protected void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
writer.WriteAttributeString("thread", loggingEvent.ThreadName);

// Append the message text
writer.WriteStartElement("log4j:message");
writer.WriteStartElement("log4j", "message", "log4net");
Transform.WriteEscapedXmlString(writer, loggingEvent.RenderedMessage,this.InvalidCharReplacement);
writer.WriteEndElement();

Expand All @@ -199,7 +199,7 @@ override protected void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
if (valueStr != null && valueStr.Length > 0)
{
// Append the NDC text
writer.WriteStartElement("log4j:NDC");
writer.WriteStartElement("log4j", "NDC", "log4net");
Transform.WriteEscapedXmlString(writer, valueStr,this.InvalidCharReplacement);
writer.WriteEndElement();
}
Expand All @@ -209,10 +209,10 @@ override protected void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
PropertiesDictionary properties = loggingEvent.GetProperties();
if (properties.Count > 0)
{
writer.WriteStartElement("log4j:properties");
writer.WriteStartElement("log4j", "properties", "log4net");
foreach(System.Collections.DictionaryEntry entry in properties)
{
writer.WriteStartElement("log4j:data");
writer.WriteStartElement("log4j", "data", "log4net");
writer.WriteAttributeString("name", (string)entry.Key);

// Use an ObjectRenderer to convert the object to a string
Expand All @@ -228,7 +228,7 @@ override protected void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
if (exceptionStr != null && exceptionStr.Length > 0)
{
// Append the stack trace line
writer.WriteStartElement("log4j:throwable");
writer.WriteStartElement("log4j", "throwable", "log4net");
Transform.WriteEscapedXmlString(writer, exceptionStr,this.InvalidCharReplacement);
writer.WriteEndElement();
}
Expand All @@ -237,7 +237,7 @@ override protected void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
{
LocationInfo locationInfo = loggingEvent.LocationInformation;

writer.WriteStartElement("log4j:locationInfo");
writer.WriteStartElement("log4j", "locationInfo", "log4net");
writer.WriteAttributeString("class", locationInfo.ClassName);
writer.WriteAttributeString("method", locationInfo.MethodName);
writer.WriteAttributeString("file", locationInfo.FileName);
Expand Down