CompanyDroneFromSector7G
CompanyDroneFromSector7G

Reputation: 4517

'ILoggingBuilder' does not contain a definition for 'AddFile'

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>();
                });
    }
}

Upvotes: 9

Views: 15814

Answers (1)

CompanyDroneFromSector7G
CompanyDroneFromSector7G

Reputation: 4517

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

Upvotes: 17

Related Questions