Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure JSON body size limit #197

Open
simonedem opened this issue Apr 4, 2023 · 1 comment
Open

Configure JSON body size limit #197

simonedem opened this issue Apr 4, 2023 · 1 comment

Comments

@simonedem
Copy link

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?

@todthomson
Copy link

todthomson commented Apr 4, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants