I have a simple C# application that I can run on a windows platform or a linux platform (CentOS 7) using mono 4.2.3.4/832de4b.
When I try to log something using log4Net 2.0.5 on a windows machine I get the following output using a RollingFileAppender:
2016-03-24 09:09:40,374 DEBUG 8 C:\src\Test\Program.cs::20::This is my debug message.
2016-03-24 09:09:40,397 INFO 8 C:\src\Test\Program.cs::21::This is my info message.
2016-03-24 09:09:40,398 WARN 8 C:\src\Test\Program.cs::22::This is my warning message.
2016-03-24 09:09:40,398 FATAL 8 C:\src\Test\Program.cs::23::This is my fatal message.
2016-03-24 09:09:40,399 ERROR 8 C:\src\Test\Program.cs::24::This is my error message.
When I copy this over to a linux box and execute using mono I get the following:
2016-03-24 09:58:58,913 DEBUG 1 ::0::This is my debug message.
2016-03-24 09:58:58,920 INFO 1 ::0::This is my info message.
2016-03-24 09:58:58,920 WARN 1 ::0::This is my warning message.
2016-03-24 09:58:58,923 FATAL 1 ::0::This is my fatal message.
2016-03-24 09:58:58,923 ERROR 1 ::0::This is my error message.
Why am I missing the file name and line numbers from my output? Ideally I would like to have this work with rsyslog but right now I'm trying to get my simple app working correctly.
NOTE: I have a wrapper class around log4net which I have implemented using the information from here.
The RollingFileAppender config looks like this:
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="test_logfile.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="50MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level %thread %file::%line::%message%newline" />
</layout>
</appender>