C# console log file
-
I have a C# 2008 console application where all the output is displayed in DOS popup windows instead of being written to a log file. Thus can you tell me what I can do to have all messages in this console application appear in a log file instead of these dos pop windows? Can you show me in code how to accomplish this goal?
-
I have a C# 2008 console application where all the output is displayed in DOS popup windows instead of being written to a log file. Thus can you tell me what I can do to have all messages in this console application appear in a log file instead of these dos pop windows? Can you show me in code how to accomplish this goal?
It's a little too big a solution to do in a single post, so I'll link you to a good CP article that will give you a full solution. log4net Tutorial[^]
I wasn't, now I am, then I won't be anymore.
-
I have a C# 2008 console application where all the output is displayed in DOS popup windows instead of being written to a log file. Thus can you tell me what I can do to have all messages in this console application appear in a log file instead of these dos pop windows? Can you show me in code how to accomplish this goal?
-
I have a C# 2008 console application where all the output is displayed in DOS popup windows instead of being written to a log file. Thus can you tell me what I can do to have all messages in this console application appear in a log file instead of these dos pop windows? Can you show me in code how to accomplish this goal?
If the following is true. 1. ONLY log output is written (presumably the case) 2. You can change the code Then you might want to try using the System.Console.SetOut() method. You can provide your own writer which you can then put the data anywhere you want.
-
I have a C# 2008 console application where all the output is displayed in DOS popup windows instead of being written to a log file. Thus can you tell me what I can do to have all messages in this console application appear in a log file instead of these dos pop windows? Can you show me in code how to accomplish this goal?
If you can change the code you can basically change all Console.WriteLine("") to a log function. Example:
public void WriteLog(string logtext){
StreamWriter writer = new StreamWriter("[path here]", true);
writer.writeLine(DateTime.Now.ToString() + ": " + text);
writer.Close();
}hope this helps.
V.
(MQOTD Rules )