I'm running a couple of console applications using task scheduler. These are applications that perform little backoffice tasks and run as C# console applications.
The applications themselves run perfectly well (i.e. one of them outputs emails at the end of its run and I'm getting these emails) but I'm having issues with getting them to log correctly. They use Log4Net and the configuration appears fine because if I run them manually they produce the logs correctly.
However when I run these under the same user account (confirmed by checking process manager) under task scheduler they don't produce any logs. Its as if they are being starved of the correct privileges (but not throwing exceptions because they execute fine) or task scheduler is somehow sandboxing the disk writes and never letting them touch the actual disk.
I originally tried writing to %AppData% but I read that task scheduler has issues with user variables. So I've now hardcoded the paths to c:\BackOffice\Logs, however this has not changed the unfortunate behaviour at all. D:
Any ideas? This is Microsoft Server 2008 R2 Datacenter running on AWS EC2.
Here is the config for log4net if that helps:
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<appender name="ConsoleAppender"
type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%ndc] - %message%newline" />
</layout>
</appender>
<appender name="FileAppender"
type="log4net.Appender.FileAppender">
<file value="c:\BackOffice\Logs\LogName_log.txt" />
<appendToFile value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="FileAppender" />
<appender-ref ref="ConsoleAppender" />
</root>
</log4net>