I have the following code to write to a log file and it works fine in my console application:
try
{
string log = "some message";
string mFileName = "some directory to the log file";
Console.WriteLine(log);
using (StreamWriter w = File.AppendText(mFileName))
{
w.WriteLine(log);
w.Dispose();
}
}
catch (Exception e)
{
Console.WriteLine("Error Log: " + e.Message);
}
But when I run the code as a service on my PC, it stops logging altogether. I've already checked and the service has same rights as me.
Please note: The service doesn't crash, it simply runs without logging.