datalust / serilog-sinks-seq

A Serilog sink that writes events to the Seq structured log server
https://datalust.co/seq
Apache License 2.0
225 stars 50 forks source link

Value must conform to exactly one of the associated schemas error when publishing to Azure Functions running with Linux operating system #195

Closed sergiojrdotnet closed 1 year ago

sergiojrdotnet commented 1 year ago

host.json

{
  "version": "2.0",
  "logging": {
    "logLevel": {
      "default": "Information",
      "AzTech": "Trace"
    },
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "Serilog": {
    "LevelSwitches": { "$controlSwitch": "Information" },
    "MinimumLevel": {
      "ControlledBy": "$controlSwitch",
      "Override": {
        "Azure": "Warning",
        "Host": "Warning"
      }
    },
    "Enrich": {
      "0": "FromLogContext",
      "1": "WithMachineName",
      "2": "WithProcessName",
      "3": "WithProcessId",
      "4": "WithExceptionDetails"
    },
    "WriteTo": {
      "0": {
        "Name": "Seq",
        "Args": {
          "controlLevelSwitch": "$controlSwitch",
          "serverUrl": "http://HOSTNAME:5341",
          "apiKey": "APIKEY"
        }
      }
    }
  }
}

Startup.cs

internal class Startup : FunctionsStartup
{
    public override void Configure(IFunctionsHostBuilder builder)
    {
        var configuration = builder.GetContext().Configuration;

        var dependencyContext = DependencyContext.Load(typeof(Startup).Assembly);

        ConfigureSerilog(builder.Services, configuration, "AzureFunctionsJobHost:Serilog", dependencyContext);
    }

    private static void ConfigureSerilog(IServiceCollection services, IConfiguration configuration, string sectionName,
        DependencyContext dependencyContext)
    {
        var config = new LoggerConfiguration().ReadFrom.Configuration(configuration, sectionName, dependencyContext);

        Log.Logger = config.CreateLogger();

        services.AddSingleton<ILoggerProvider>(_ => new SerilogLoggerProvider(dispose: true));
        services.AddSingleton<ILoggerFactory>(_ => new SerilogLoggerFactory(dispose: true));
    }
}

Publish errors

23/12/2022 05:44:45
System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. 
   --- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. <---

Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. 

image

sergiojrdotnet commented 1 year ago

Host.json configuration is not associated with publish errors