0

Trying to follow the docs here
https://github.com/serilog/serilog-extensions-hosting

Have these packages referenced in my project

<PackageReference Include="Serilog" Version="2.8.0" /> <PackageReference Include="Serilog.Sinks.File" Version="4.0.0" /> 

When I try to add the line UseSeriLog, it cant be recognized

Error CS1061 'IHostBuilder' does not contain a definition for 'UseSeriLog' and no accessible extension method 'UseSeriLog' accepting a first argument of type 'IHostBuilder' could be found (are you missing a using directive or an assembly reference?)

My main method:

private static async Task Main(string[] args) { var isService = !(Debugger.IsAttached || args.Contains("--console")); Log.Logger = new LoggerConfiguration() .WriteTo.File(@"d:\temp\consoleapp.log") .CreateLogger(); var hostBuilder = new HostBuilder() .ConfigureHostConfiguration(configHost => { configHost.AddCommandLine(args); }) .UseContentRoot(@"D:\Services\BldgRunner\") .ConfigureAppConfiguration((hostingContext, config) => { var env = hostingContext.HostingEnvironment; config.AddCommandLine(args); config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); config.AddEnvironmentVariables(); }) .ConfigureServices((hostContext, services) => { //Inject additional services as needed services.AddHostedService<JobRunner>(); }) **.UseSeriLog()** .Build(); if (isService) { await hostBuilder.RunAsServiceAsync(); } else { await hostBuilder.RunConsoleAsync(); } } 

1 Answer 1

1

You need to install Serilog.Extensions.Hosting for use with a generic host.

<PackageReference Include="Serilog.Extensions.Hosting" Version="3.0.0" /> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.