2

I try to upgrade .net core sdk from 2.2 to 3.1 in my project. In .net core sdk 2.2, I used loggerFactory.AddDebug(Enum.Parse<LogLevel>(this.Configuration.GetSection("Logging:Debug:LogLevel:Default").Value)); works fine. But in .net core sdk 3.1, I use same code, I getting "No overload for method "AddDebug" takes 1 arguments" error. I installed Microsoft.Extensions.Logging package v3.1.5 via nuget package manager.

xangkcl
  • 57
  • 1
  • 7

1 Answers1

1

I getting "No overload for method "AddDebug" takes 1 arguments" error

If you check the definition of AddDebug() method in version 2.2 project, you would find the method is obsolete and the AddDebug(this ILoggingBuilder builder) is recommended alternative.

    //
    // Summary:
    //     Adds a debug logger that is enabled for Microsoft.Extensions.Logging.LogLevels
    //     of minLevel or higher.
    //
    // Parameters:
    //   factory:
    //     The extension method argument.
    //
    //   minLevel:
    //     The minimum Microsoft.Extensions.Logging.LogLevel to be logged
    [Obsolete("This method is obsolete and will be removed in a future version. The recommended alternative is AddDebug(this ILoggingBuilder builder).")]
    public static ILoggerFactory AddDebug(this ILoggerFactory factory, LogLevel minLevel);

And above method has been removed from Microsoft.Extensions.Logging namespace in version 3.0 and higher.

enter image description here

Fei Han
  • 26,415
  • 1
  • 30
  • 41
  • 1
    Thanks a lot for your answer. I got rid of this problem with the solution given in the link.(https://stackoverflow.com/questions/53840298/how-to-fix-obsolete-iloggerfactory-methods). – xangkcl Jun 28 '20 at 06:03
  • The solution is same as I mentioned in above reply, using LoggingBuilder.AddDebug() is recommended alternative in 3.0+ project. – Fei Han Jun 29 '20 at 01:34