How to do it...

  1. Open Visual Studio 2017.
  2. Now, open the solution from the previous recipe. Click File | Open | Open Project/Solutionor press Ctrl + Shift + Oand select the Chapter10.Logging solution. 
  3. Press Ctrl + Shift + B for a quick build to check that everything is fine. 
  1. The Solution Explorer should look like this:
  1. Now, double-click on the LoggerDemo.cs label to open the code window.
  2. Scroll down until you reach the WriteLog() method.
  3. 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} ...

Get .NET Standard 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.