ILoggingBuilder' does not contain a definition for 'AddFile' and the best extension method overload 'FileLoggerExtensions.AddFile(ILoggerFactory, IConfigurationSection)' requires a receiver type of 'ILoggerFactory'
Note the line in the code marked with <== Exception
.
According to everything I can find online this should work, but I get the error above.
I can't find anything to suggest what the problem is.
Probably something daft. Any suggestions gratefully received!
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace my.namespace
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddFile("..."); // <== Exception
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
ILoggingBuilder' does not contain a definition for 'AddFile' and the best extension method overload 'FileLoggerExtensions.AddFile (ILoggerFactory, IConfigurationSection)' requires a receiver type of 'ILoggerFactory' Note the line in the code marked with <== Exception.
'ILoggerFactory' does not contain a definition for 'AddConsole' and the best extension method overload 'ConsoleLoggerExtensions.AddConsole (ILoggingBuilder)' requires a receiver of type 'ILoggingBuilder' I'm using NET Core 3.0 and I have the following NuGet packages installed.
It gives the following error: 'ILoggerFactory' does not contain a definition for 'AddConsole' and the best extension method overload 'ConsoleLoggerExtensions.AddConsole (ILoggingBuilder)' requires a receiver of type 'ILoggingBuilder' I'm using NET Core 3.0 and I have the following NuGet packages installed.
‘ILoggerFactory’ does not contain a definition for ‘AddLog4Net’ and no accessible extension method ‘AddLog4Net’ accepting a first argument of type ‘ILoggerFactory’ could be found (are you missing a using directive or an assembly reference?) Run this NUGET Command from the Package Manager Console in Visual Studio.
Found the answer. I was using an earlier version of the package.
The one I needed was still a dev version, although dated 2018.
> Install-Package Serilog.Extensions.Logging.File -Version 2.0.0-dev-00024
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With