Additivity is set to true by default, that is children inherit the appenders of their ancestors by default. If this variable is set to false then the appenders found in the ancestors of this logger are not used.
In your case, the log file will be in bin\Debug\netcoreapp3.
log4net doesn't support the concept of structured logging. Like shown in the conversionPattern element in the XML configuration, you have some variables to play with when writing to the storage. But including properties like FirstName in the Serilog example isn't available.
You are getting duplicated because you are telling it to log messages twice. I wouldn't recommend using additivity here since you might experience some side effects, simply remove unnecessary configuration:
<root>
<level value="WARN" />
<appender-ref ref="Console" />
<appender-ref ref="LogFile" />
</root>
<logger name="myprogram">
<level value="INFO" />
</logger>
You don't need to indicate the appender-ref in the logger myprogram since it will inherit them from the root logger; if you specify them again it will log twice.
Try with this change, setting additivity to false.
<root>
<level value="WARN" />
<appender-ref ref="Console" />
<appender-ref ref="LogFile" />
</root>
<logger name="myprogram" additivity="false">
<level value="INFO" />
<appender-ref ref="Console" />
<appender-ref ref="LogFile" />
</logger>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With