From the course: C#: Design Patterns Part 1

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Adapter in C#: Adapt FileStream to ILogger

Adapter in C#: Adapt FileStream to ILogger - Python Tutorial

From the course: C#: Design Patterns Part 1

Start my 1-month free trial

Adapter in C#: Adapt FileStream to ILogger

- [Instructor] Let's build a simple adapter example. I want to use Microsoft's logger to log directly to a file. This functionality is not actually built into the logger for a myriad of good reasons that we don't need to get into now, Microsoft's ILogger interface is how I want my application to be able to log to disk. In the future, my code won't need to change if I want to use the built in configurable logging to write to another source. Since I know that I want to write to a file for now, I'm going to adapt file system access to the logging interface. We'll start with another new console app. I've named it adapter. I'll start by opening the terminal and adding the Microsoft logging instructions. This is going to give us the ILogger interface and the Microsoft logging extensions. Then I'll get that out of the way. In the program, we'll start with a couple using statements. The logging extensions, and system dot text…

Contents