I am writing a small program in C# and as a part of it I need it to write data out to a log file. for this I am using the next command:
Trace.Listeners.Add(new TextWriterTraceListener(Constants.LOG_FILE_NAME));
Trace.AutoFlush = true;
Trace.Indent();
Trace.WriteLine("\n~~~~~~~~~~~~~~\n" + DateTime.Now + ": start writing to file");
It works perfectly when running from visual studio, but when I am compiling a release version, it does not writing the log file and instead (sometimes) I am getting a file with the name 0
and zero size, and there is no content inside it.
I am suspecting this is a permissions problem, how can I check if this is the reason?
If someone familiar with this issue and can help me with that I'll be thankful.
Edit
I forgot the mention that the 'Define Trace Constant' is checked in the build properties under all the configurations, so this can't be the reason.