datalust/serilog-sinks-seq

Configure JSON body size limit

simonedem opened this issue · 1 comments

I get the following error in the application: Event JSON representation exceeds the body size limit 262144; sample: ...

GlobalConfiguration.Configuration.UseSerilogLogProvider();

var logger = new LoggerConfiguration()
    .ReadFrom.Configuration(builder.Configuration)
    .Filter.ByExcluding(logEvent => logEvent.Exception is OperationCanceledException)
    .CreateLogger();

builder.Host
    .UseSerilog(logger);

In my appsettings.json I have the following configuration:

  "Serilog": {
    "Using": [
      "Serilog.Sinks.Seq",
      "Serilog.Exceptions",
      "Serilog.Enrichers.CorrelationId"
    ],
    "MinimumLevel": "Debug",
    "WriteTo": [
      {
        "Name": "Seq",
        "Args": {
          "serverUrl": "https://........",
            "restrictedToMinimumLevel": "Information"
          }
        }
    ],
    "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId", "WithExceptionDetails", "WithCorrelationId" ],
    "Properties": {
      "ApplicationName": "Moonshine API"
    }
  }

I see similar thread, but hey use a slightly different configuration.
I'd like to increase the batch size limit, where do I have to put this setting in my client code?

Hi @simonedem,

The default is 256KiB, which should be plenty for any text-based log event that doesn't contain binary data (e.g. Base64 encoded binary data, as in the similar thread), or other issues (see here, under "settings you shouldn't need to touch):
https://blog.datalust.co/collecting-serilog-events/

While we don't recommend this (rather, we feel its much wiser to work out why your logs are so large and fix that instead), you could achieve that using eventBodyLimitBytes and following the additional configuration info here:

Cheers,

Tod.