Hi devs,

 

I'm looking to make a change and following the contributions guidelines with
this email.

 

When using log4net 2.0.8 in aspnetcore 2.0 I ran across an issue with
XmlLayoutSchemaLog4j.cs. The image attached shows the exception. The problem
is that performing a writer.WriteStartElement with the value log4j:event,
the XML has not previously defined the namespace and considers the colon an
invalid character. My fix is to properly use the prefix and ns parameters
when writing the start element like so: writer.WriteStartElement("log4j",
"event", "log4net");

 

I have not yet created the PR, but here's the compare:
https://github.com/apache/logging-log4net/compare/master...dmarlow:fix/prefi
x-ns (maybe the PR looks strange because of whitespace/tab changes? I can
review if desired).

 

The XML should be identical with the exception of the xmlns attribute being
added. Because it is cached, it should only show up in the first element.

 

Example XML with the change above made:

 

<log4j:event logger="Degreed.Api.Startup" timestamp="1523895623412"
level="INFO" thread="1" xmlns:log4j="log4net">

       <log4j:message>Starting</log4j:message>

       <log4j:properties>

              <log4j:data name="log4japp" value="NOT AVAILABLE" />

              <log4j:data name="log4jmachinename" value="dm1" />

              <log4j:data name="role" value="Api" />

              <log4j:data name="log4net:HostName" value="dm1" />

              <log4j:data name="pid" value="7896" />

              <log4j:data name="hostname" value="DM1" />

              <log4j:data name="env" value="Local" />

              <log4j:data name="log4net:UserName" value="NOT AVAILABLE" />

              <log4j:data name="log4net:Identity" value="NOT AVAILABLE" />

       </log4j:properties>

       <log4j:locationInfo class="?" method="?" file="?" line="?" />

</log4j:event>

Reply via email to