In order to move data for a couple products, I have created a C# console application that uses Log4Net to track progress. Log4Net is configured in the console apps App.Config file and currently has two appenders, a ConsoleAppender and a RollingLogFileAppender.
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs\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 %-5level %logger %method - %message%newline%exception" />
</layout>
</appender>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level %logger %method - %message%newline%exception" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingLogFileAppender" />
<appender-ref ref="ConsoleAppender" />
</root>
This application and its logging are working when run standalone. Now in order to automate the running of this console app, I am creating Windows Service to run the console app. The application does not require any user input so I did predict any issues when running it through the service. When the service runs it successfully calls the console application and I can see the results of its work, however, the logging does not seem to working. The logs at the location of the executable being called are not changing and I cannot find another instance of the log elsewhere on my machine. The service is running as LocalSystem so permissions should not be an issue. I have tried calling the application with the following settings:
ProcessStartInfo processStartInfo = new ProcessStartInfo(@"C:\Constellation\Dev\Caelum\Caelum\bin\Debug\Caelum.exe");
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processStartInfo.CreateNoWindow = true;
processStartInfo.UseShellExecute = false;
processStartInfo.RedirectStandardError = true;
processStartInfo.RedirectStandardInput = true;
processStartInfo.RedirectStandardOutput = true;
I have tried both with and without the output redirects and neither worked. Any suggestions are greatly appreciated.