Use LoggerFactory.Create(...) instead of new LoggerFactory()
Recipe ID
OpenRewrite.Recipes.CSharp.Migration.Dotnet.AspNetCore3.UseLoggerFactoryCreateArtifactOpenRewrite.Recipes.CSharp.Migration.DotnetRewrites 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.UseLoggerFactoryCreateIf the recipe isn’t available locally, install it with:
mod config recipes nuget install OpenRewrite.Recipes.CSharp.Migration.Dotnet