Let's get back to the root folder by typing the following command:
$ cd ..
Now, in the root of the solution directory, type the following command to open Visual Studio Code using the current directory:
$ code .
In Visual Studio Code, expand the Chapter3 label and expand Chapter3.LogFile.LogAppMvc.
Again, expand the Controllers folder and click on HomeController.cs:
In HomeController.cs, add the following using directive to the last line of the using directives block:
usingChapter3.LogFile.LogLib;
Now, next to the starting curly bracket of the Index method of the HomeController class, add the following code:
TextLog logFile =newTextLog(); logFile.WriteLog("You are in the Index action."); logFile.CloseLog();
Let's add more code inside the About method too:
TextLog logFile =newTextLog(); logFile.WriteLog("You are in the About action."); logFile.CloseLog();
Do the same to the Contact method as well:
TextLog logFile =newTextLog(); logFile.WriteLog("You are in the Contact action."); logFile.CloseLog();
Now we are done with adding code, let's navigate to Chapter3.LogFile.LogAppMvc:
$ cd Chapter3.LogFile.LogAppMvc/
Let's run the application:
$ dotnet run
Open your favorite browser, type localhost:5000 in the address bar, and press Enter. Click on the navigation links for Home, About, and Contact a few times.
Close the browser.
Now go to Visual Studio Code, expand the Chapter3 label, and expand Chapter3.LogFile.LogAppMvc. You should see a file named server_log.txt in the root:
Now click on the server_log.txt filename to see the output: