4
Answers

C# 2008 write to console log file

dc

dc

12y
4k
1
In an existing C# 2008 application, I want to have error messages written to a log file that can be saved and looked at later for a reference. I basically want to generate console.writeline messages and save the output. I could also use something like objUtil.LogMessage to accomplish this goal.

I would like to accomplish the following goals:

1. Do I need to 'open' some kind of a log file. If so, how would you code this?
2. I would like to save ex.messages that are located in try catch blocks. Does this require any special code?
3. I would like to open and save the log files to a certain directory path location.

4. I could possibly use objUtil.LogMessage and/or console.writeline separate or together? Is this possbile, if so how is this possible?

Thus can you tell me and or show me in code how to accomplish any and/or all of the goals I just listed above?
Answers (4)