I m implementing a windows service with log4net logger. The thing is when I debug the service, the log is created but after installing, the log is not creating. I used app.config file and another config file to add configuration details
This is my app.config file
<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> <appSettings>
<!--Log file configuration-->
<add key="log4net.Config" value="log4.config"/>
<add key="log4net.Config.Watch" value="True"/>
<add key="log4net.Internal.Debug" value="false"/> </appSettings> </configuration>
and this is another config file named log4.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="D:\applications\ActualSys\FujiOrder\log\log.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="RollingFileAppender" />
</root> </log4net> </configuration>
I am using following way to create log messages
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
log.Info("Interface " + CODE + " - sendOrderThreadRoutine started!");
This works perfectly when I m debugging. But this is not working after install the service.
I have tried following code snippets with AssemblyInfo.cs file. But the issue has not fixed
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
When I install the service, below files are in the installed folder
- .exe file
- .config file
- log4net.dll
Even though I can see lot of examples for log file is not creating in the debug phase, I couldn't find articles about the same issue in the installation phase.