Skip to main content

Posts

Tuning the default logging providers in ASP.NET Core through configuration

After deploying a new application to production, we noticed that a lot of extra log messages where written to the EventLog. As we didn't configure the EventLog logging provider in our application, we did not expect this. Turns out that when you create a new ASP.NET Core application with WebApplication.CreateBuilder , you get a set of logging providers activated out-of-the-box. So the question becomes: which providers are enabled, and how do you get rid of the ones you don’t need? Which providers are enabled by default? The default builder registers the following providers: Console Debug EventSource EventLog (Windows only) You can verify this yourself by looking at the registered ILoggerProvider services: var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); var providers = app.Services.GetServices<ILoggerProvider>(); foreach (var provider in providers) { Console.WriteLine(provider.GetType().Name); } On Windows this pr...
Recent posts

Getting started with DSC 3.0 – Part 6: Using the DSC MCP server with your AI coding tools

Throughout this series I ran into the same kind of problem again and again. Which resource type do I need? What is the exact name and casing of a property? Which adapter runs it? Names also change between versions. The Windows PowerShell adapter got a new name in 3.2, and the dsc mcp command became dsc server in 3.3. An AI assistant that writes DSC YAML for you can easily get this wrong. It guesses, based on what it saw during training. DSC 3.0 has a built-in answer for that: an MCP server that lets the assistant ask DSC itself. Note: this post is part of a bigger series on Microsoft Desired State Configuration. Getting started with DSC 3.0 – Part 1: What is DSC and what changed? Getting started with DSC 3.0 – Part 2: Managing a Windows service end to end Getting started with DSC 3.0 – Part 3: Capturing the current state with dsc config export Getting started with DSC 3.0 – Part 4: Configuring IIS with multiple resources and dependsOn Getting started with DSC 3.0 – Part 5: Guard...

Getting started with DSC 3.0 – Part 5: Guarding your configuration with Assertion

At the end of the previous post I said that dependsOn only decides the order in which resources are processed. It doesn't check that the resource you depend on is actually in the desired state. Sometimes that's not enough. You want to say "only touch this machine if it's Windows Server 2025", or "only configure the website if IIS is really installed". That's what the Microsoft.DSC/Assertion resource is for. Note: this post is part of a bigger series on Microsoft Desired State Configuration. Getting started with DSC 3.0 – Part 1: What is DSC and what changed? Getting started with DSC 3.0 – Part 2: Managing a Windows service end to end Getting started with DSC 3.0 – Part 3: Capturing the current state with dsc config export Getting started with DSC 3.0 – Part 4: Configuring IIS with multiple resources and dependsOn Getting started with DSC 3.0 – Part 5: Guarding your configuration with Assertion (this post) What is an assertion? An assertio...

Getting started with DSC 3.0 – Part 4: Configuring IIS with multiple resources and dependsOn

Until now we configured one resource at a time. A real server needs several, and they depend on each other. You can't create a website before IIS is installed, and you can't attach a web application to a website that doesn't exist yet. In this post we set up IIS, an application pool, a website and a web application in a single configuration document, and use dependsOn to control the order. Note: this post is part of a bigger series on Microsoft Desired State Configuration. Getting started with DSC 3.0 – Part 1: What is DSC and what changed? Getting started with DSC 3.0 – Part 2: Managing a Windows service end to end Getting started with DSC 3.0 – Part 3: Capturing the current state with dsc config export Getting started with DSC 3.0 – Part 4: Configuring IIS with multiple resources and dependsOn (this post) What we are building Six resource instances, with these dependencies: IIS (Windows feature): no dependencies Site folder and App f...

Getting started with DSC 3.0 – Part 3: Capturing the current state with dsc config export

In the previous post we wrote a configuration document for a single service by hand. That works when you know exactly what you want to manage. But what if you inherit a machine and have no idea what's configured on it? Or you have one server that works fine and you want the others to look the same? Writing the document from scratch is slow and you will forget things. That's what dsc config export is for. Note: this post is part of a bigger series on Microsoft Desired State Configuration. Getting started with DSC 3.0 – Part 1: What is DSC and what changed? Getting started with DSC 3.0 – Part 2: Managing a Windows service end to end Getting started with DSC 3.0 – Part 3: Capturing the current state with dsc config export (this post) What does export do? The export command inspects the system and generates a configuration document that contains every instance of the resources you ask for. The result is a normal configuration document, so you can use it ...

Getting started with DSC 3.0 – Part 2: Managing a Windows service end to end

In the previous post we looked at what DSC is and what changed in 3.0. Time to put it to work. A Windows service is a good first example. It's something most teams have, and it's easy to break without anybody noticing. Someone sets the start type to Manual while troubleshooting, forgets to put it back, and a few weeks later the service doesn't come up after a reboot. Let's use DSC to describe the state we want and keep it that way. Note: this post is part of a bigger series on Microsoft Desired State Configuration: Getting started with DSC 3.0 – Part 1: What is DSC and what changed? Getting started with DSC 3.0 – Part 2: Managing a Windows service end to end (this post) What you need DSC v3.3 or later, because Microsoft.Windows/Service was added in that release A Windows machine An elevated terminal for the set operation Check your version first: dsc --version Remark: the resource can only manage services that are already regis...

Getting started with DSC 3.0 – Part 1: What is DSC and what changed?

If you've worked with PowerShell DSC before, you probably remember writing a Configuration block, generating a MOF file and hoping the Local Configuration Manager did what you expected.  DSC 3.0 throws most of that away and provides a more modern incarnation of infrastructure-as-code.  Let me explain what it is, and what makes 3.0 different. What is DSC? Desired State Configuration is a declarative way to manage a system. You describe what the system should look like, not how to get there. DSC figures out the rest. It is kind of the first incarnation of Infrastructure as Code. Three concepts are enough to understand DSC: Configuration document: a file that describes the desired state Resource: the piece that knows how to read and change one specific thing (a registry key, a service, a package, ...) Operations: what you can do with a resource: get , test , set and export So the question becomes: if the concepts stays the same, what changed in 3.0?...