Tag Archives: console

Logger doesn’t work in scheduled task?

It’s weird. I deployed a console application which has a logging feature that writes to a text file. By default, the log file is in the same directory as the executable. Ok, so if I remote to the server and double click the executable, everything works fine and a nice log file appears (with today’s date) and tracing information shows up in there and all is right with the world.

Then I schedule the console app to be run automatically every so often. It seems to run fine, I can even run the scheduled task manually from the Task Scheduler UI, but the log file NEVER appears (or if it exists it’s never updated). Hmmmmmm.

Finally I noticed a curious field on the Task Scheduler’s “Actions” tab. It’s a text box labeled, “Start in (optional):”

Well, don’t be fooled, it’s certainly NOT optional as far as getting my logger to work. I went ahead and filled that in with the path to my console app and now my log files are working.

So… what happened all those times the program was running and NO log file was being generated? Did they all end up in some weird ‘relative’ location (a quick search didn’t turn up anything)? And why didn’t the logger complain when it tried logging to… where? Anyway it’s working now, but the ignorance is gnawing at me.