Logging

Learning Goals

  • Understand the benefits of logging
  • Be able to implement logging to the console and a file in a .NET application
  • Practice the skill of self-directed learning and building

Collecting Questions

In preparation for today’s lesson, you were asked to imagine that you are assigned the task “Add logging to our MVC Movies application.”. Then you were asked to brainstorm questions you would want to figure out answers to before you even think about how to write the code for this task.

In your group of 3-4, share the questions each of you came up with. Then narrow down to the three questions that seem most important.

When we come back together your instructor will call on groups and compile a list of top questions in Slack, each as a separate post.

With your partner, discuss the following question: If you were really on a dev team, how might you go about figuring out the answers to these questions?


When we come back together your instructor will call on folks to share. I encourage you to write down what’s share to start building your “Tools for my First Job”.

Research

For today, we’re going to focus on the research approach.

Your instructor will assign each questions to pairs by putting your names on the Slack message. You will have 20 minutes to research and write up your answer in a thread on that post. Feel free to also add favorite resources you found related to that question!

When we come back together each pair will share out what they found.

Set Up

Today we will again be working in MvcMovies, building off of the code written in the error handling lesson. You will also be using traditional driver/navigator pair programming. Before we dive into building, we need to do some set up.

With your partner do the following four things:

  • Choose whose code you’re going to build off of today
  • That person will commit their error handling code (you won’t be able to push, but we still want to commit so that you have your error handling as a separate version)
  • Set up a Visual Studio Pair programming session. Here is a video on how to do that.
  • Start the app and make sure it runs successfully

Emoji react in Slack once you have finished these four steps.

The Task

Your task is to “Add logging to our MVC Movies application.” You will be working with a partner and working in the traditional pair programming style, switching at least every 30 minutes between driver and navigator.

This is a very open-ended task!

Here are two guide posts:

  • You should log both to a file and to the console

  • Everyone should use the logging library Serilog. It’s highly recommended in the .NET community and while there are many options out there it will be easier to help each other debug if we stick to the same tech stack. There is a built in logger in .NET you can also look into but “ASP.NET Core doesn’t include a logging provider for writing logs to files.” so for that goal we need another tool.

If other questions come up as you are working, post them in the codehelp Slack channel!

✅Deliverable✅: With your partner write up the steps required to log to a file and the console in a .NET application. Include screenshots of what the log file and console log should look like when it’s working. A teammate should be able to follow your guide and get an initial message to log. Include any bugs/problems you ran into during set-up so that your teammate can avoid making the same mistake. Send these instructions in a slack message to your instructor.

Once you complete this deliverable, dive deeper into the world of .NET logging! You want to build the highest quality logging you can in the time block provided.

At some point your instructor will call the class back together to talk through some questions as a group and discuss tradeoffs you have run into.

Tiny Next Goal

Because this is such an open-ended challenge, it can be overwhelming to figure out where to start and how to move forward. To help us stay focused, I want us to use the “Tiny Next Goal” structure.

At every point, you and your partner should have a “Tiny Next Goal” that you’re working towards. This is the smallest goal you can think of that gets you closer to a high-quality logging implementation. Some examples of Tiny Next Goals for someone building their first HTML page might be, “Get the page to load with one H1 header on it”, “Add a list to the page”, “Link a CSS style sheet to the page that I know works because it changes the page background color”, “Add spacing around items in the list”. Notice how we focus on getting something working, and then update the goal to more closer to the ideal.

Periodically throughout worktime, I will post a Slack Thread for each group to share the “Tiny Next Goal” they are currently working towards. If your goal feels large, your instructor will encourage you to break it down into an even smaller part. If you’re ever stuck on what to have as your next goal, reach out, your instructor will be happy to help.

Your instructor will now drop the pairs into breakout rooms where you will decide on your first Tiny Next Goal and post it to the a thread in Slack. Then get started working towards that goal!

Lesson Search Results

Showing top 10 results