0

I've got an azure function I need to add logging to logz.io and I'm using Serilog's sink to perform this. On web application with the same key it works in this function not.

here's the program.cs

using Microsoft.Extensions.Hosting;

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults().RegisterLinq2DbConnection().RegisterLogzio()
    .Build();

host.Run();

and here's the extension method

 public static class LoggerExtensions
    {
        public static IHostBuilder RegisterLogzio(this IHostBuilder builder)
        {
            builder.ConfigureLogging((hostContext, builder) =>
            {
                Log.Logger = new LoggerConfiguration()
                    .WriteTo.LogzIo("key", "Information",
                        new LogzioOptions
                        {
                            RestrictedToMinimumLevel = LogEventLevel.Debug,
                            Period = TimeSpan.FromSeconds(15),
                            LogEventsInBatchLimit = 50
                        }).CreateLogger();

                builder.Services.AddSingleton<ILoggerProvider>(new SerilogLoggerProvider(Log.Logger));
                builder.AddSerilog(Log.Logger,dispose: true);
            });

            return builder;
        }
    }

Am I missing something?

In the web application I'm using

"WriteTo": [
    
      {
        "Name": "LogzIoDurableHttp",
        "Args": {
          "requestUri": "https://listener-nl.logz.io:8071/?type=app&token=key"
        }
      }
    ],
advapi
  • 3,661
  • 4
  • 38
  • 73

0 Answers0