← All recipes
Moderne licensed

Use LoggerFactory.Create(...) instead of new LoggerFactory()

Recipe IDOpenRewrite.Recipes.CSharp.Migration.Dotnet.AspNetCore3.UseLoggerFactoryCreateArtifactOpenRewrite.Recipes.CSharp.Migration.Dotnet

Rewrites the obsolete new LoggerFactory() plus ILoggerFactory.Add*() provider configuration to LoggerFactory.Create(builder => ...), moving each provider registration onto the ILoggingBuilder. Handles both the chained form and the form where registration calls follow the declaration as separate statements. Argument shapes with no ILoggingBuilder equivalent are left in place and flagged for manual migration.

Single recipecsharpaspnetcoremigrationloggingProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe OpenRewrite.Recipes.CSharp.Migration.Dotnet.AspNetCore3.UseLoggerFactoryCreate

If the recipe isn’t available locally, install it with:

mod config recipes nuget install OpenRewrite.Recipes.CSharp.Migration.Dotnet