My log4net is creating an empty log file in my debug/release folders for some reason. An example filename is "(null) 20150409.txt".
I'm not sure how to tell it not to do that. I am programmatically configuring log4net, but this empty file is created before the configuration routine is actually run, perhaps as a result of the App.config file itself.
Here is the App.config file:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/>
</configSections>
<log4net>
<root>
<level value="ALL"/>
<appender-ref ref="LogFileAppender"/>
</root>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender, log4net">
<!--http://logging.apache.org/log4net/release/config-examples.html-->
<!--http://logging.apache.org/log4net/release/faq.html-->
<!--<param name="File" value="C:\Images\log-file.txt" />-->
<file type="log4net.Util.PatternString" value="%property{LogFileName}"/>
<staticLogFileName value="false"/>
<param name="AppendToFile" value="true"/>
<rollingStyle value="Date"/>
<datePattern value="' 'yyyyMMdd'.txt'"/>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
</layout>
</appender>
</log4net>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
</configuration>
Here is the C# configuration code (which appears to work fine):
log4net.GlobalContext.Properties["LogFileName"] = LogFileName;
// Full path to log file
log4net.Config.XmlConfigurator.Configure();
Log.Debug("CV3 Launched with log file located here: " + LogFileName);
How do I prevent this empty file from being created without affecting the rest of the logging which is working fine?