- Open Visual Studio 2017.
- Now, open the solution from the previous recipe. Click File | Open | Open Project/Solution, or press Ctrl + Shift + O, and select the Chapter10.Logging solution.
- Press Ctrl + Shift + B for a quick build to check that everything is fine.
- The Solution Explorer should look like this:
- Now, double-click on the LoggerDemo.cs label to open the code window.
- Scroll down until you reach the WriteLog() method.
- Replace the current code with the following:
try { if (!File.Exists(logFileName)) { logFile = File.CreateText(logFileName); } else { logFile = File.AppendText(logFileName); } logFile.WriteLine($"{DateTime.Now} ...