Open Closed

Log for Console App not working #10660


0
andmattia created

Abp 4.8.1

Hi I've a console application that works on ABP + HangFire.

on Program.cs I've

 var host = Host.CreateDefaultBuilder(args);
            host.ConfigureAppConfiguration(
                (hostContext, config) =>
                {
                    config.SetBasePath(Directory.GetCurrentDirectory());
                    config.AddJsonFile("appsettings.json", false, true);
                }
            );

            host.ConfigureLogging(
                loggingBuilder =>
                {
                    loggingBuilder.ClearProviders();

                    var configuration = new ConfigurationBuilder()
                        .AddJsonFile("appsettings.json", false, true)
                        .AddEnvironmentVariables()
                        .Build();
                    var loggerConfig = new LoggerConfiguration()
                        .ReadFrom.Configuration(configuration);


                    var logger = loggerConfig.CreateLogger();
                    loggingBuilder.AddSerilog(logger, dispose: true);
                }
            );

So I see that HangFire logs work beacuse HF internlly search the logger provider how can I tell to ABP to use my log model?


1 Answer(s)
  • 0
    andmattia created

    I found a solution

    Move on start program Log stiatic definition and use generic logFactory to inject on Abp