serilog-sinks-seq icon indicating copy to clipboard operation
serilog-sinks-seq copied to clipboard

Configure JSON body size limit

Open simonedem opened this issue 1 year ago • 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?

simonedem avatar Apr 04 '23 09:04 simonedem

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:

  • https://docs.datalust.co/discuss/58d580adb2ce712f0022c86c
  • https://stackoverflow.com/questions/66041392/problems-ingesting-events-into-seq-from-serilog
  • https://github.com/datalust/serilog-sinks-seq/issues/111

Cheers,

Tod.

todthomson avatar Apr 04 '23 21:04 todthomson