Hello,
I have c# app that logs xml file
using log4net and log4net.Layout.XmlLayout
(see configuration below).
The generated log events contains
message ang name-value collection:
<log4net:**message**><Message from catch block<</log4net:message>
<log4net:properties>
<log4net:data name="RequestId" value="40000016-0007-ff00-b63f-84710c7967bb" />
<log4net:data name="**RequestPath**" value="/WeatherForecast" />"
<log4net:data name="log4net:HostName" value="DESKTOP-XX" />
...
</log4net:properties>
My questions:
1.how can i get event where all the name-value keys are flat fields.
eg, message and RequestPath are both simple fields of the envent ?
2. do you recommand json ?
log4net configuration
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value=".\Log_AppName.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRoolBackups value="100" />
<maximumFileSize value="10Mb" />
<staticLogFileName value="true"/>
<preserveLogFileNameExtension value="true"/>
<layout type="log4net.Layout.XmlLayout" />
<filter type="log4net.Filter.levelRangeFilter">
<levelMin value="INFO" />
</filter>
</appender>
Example of log entry
<log4netevent logger="WebApplication2.Controllers.WeatherForecastController" timestamp="2023-12-19T11:26:27.8096148+02:00" level="FATAL" thread="5" domain="WebApplication2" username="DESKTOP-LU6BPF1\Regina" xmlns:log4net="log4net"><log4net:message>Message from catch block</log4net:message><log4net:properties><log4net:data name="RequestId" value="40000016-0007-ff00-b63f-84710c7967bb" /><log4net:data name="RequestPath" value="/WeatherForecast" /><log4net:data name="SpanId" value="20d3c520cca51344" /><log4net:data name="TraceId" value="85283cc569e2b94283c6bc467d518f6d" /><log4net:data name="ActionName" value="WebApplication2.Controllers.WeatherForecastController.Get (WebApplication2)" /><log4net:data name="log4net:HostName" value="DESKTOP-LU6BPF1" /><log4net:data name="ParentId" value="0000000000000000" /><log4net:data name="ActionId" value="5c7d478e-ff22-4c2b-9f9a-01429a9e18a5" /></log4net:properties><log4net:exception>System.Exception: This is my Exception
at WebApplication2.Controllers.WeatherForecastController.Get() in C:\R&D\Solution1\WebApplication2\Controllers\WeatherForecastController.cs:line 37</log4net:exception></log4netevent>