Skip to content

Breaking changes

Mykhailo Shevchuk edited this page Apr 1, 2022 · 12 revisions
  • LokiJsonTextFormatter is used as a default text formatter. Removed property outputTemplate
  • Removed interface ILabelAwareTextFormatter
  • Redesigned approach of mapping properties to labels: removed filtrationMode and filtrationLabels, added propertiesAsLabels
  • Properties, mapped to the labels won't be passed to the text formatter
  • Redesigned behavior of log level data (level label): removed createLevelLabel
  • Added IReservedPropertyRenamingStrategy and reservedPropertyRenamingStrategy configuration property

More detailed description and reasons behind this changes are described here

  • Now level label is not created by default

To keep previous behavior set createLevelLabel to true at sink configuration

 .WriteTo.GrafanaLoki(
                    "http://localhost:3100",
                    createLevelLabel: true)
      {
        "Name": "GrafanaLoki",
        "Args": {
          "uri": "http://localhost:3100",
          "createLevelLabel": true
        }
      }
  • Deprecated dependency Serilog.Sinks.Http
  • Replaced IHttpClient with ILokiHttpClient Migration guide: You will have to migrate your code if you've implemented your own version of ILokiHttpClient. The signature of method ILokiHttpClient.PostAsync (before upgrade IHttpClient.PostAsync has changed from Task PostAsync(string, HttpContent) to Task PostAsync(string, Stream).

Before upgrade:

public class CustomLokiHttpClient : IHttpClient
{
  // Code removed for brevity...

  public async Task<HttpResponseMessage> PostAsync(string requestUri, HttpContent content)
  {
    // Here you probably have some code updating the content,
    // and then you send the request
    return await httpClient.PostAsync(requestUri, content)
  }
}

After update:

public class CustomLokiHttpClient : ILokiHttpClient
{
  // Code removed for brevity...

  public async Task<HttpResponseMessage> PostAsync(string requestUri, Stream contentStream)
  {
      using var content = new StreamContent(contentStream);

      // Here you probably have some code updating the content,
      // and then you send the request
      return await httpClient.PostAsync(requestUri, content)
  }
}
  • Removed DurableGrafanaLokiUsingTimeRolledBuffers and DurableGrafanaLokiUsingFileSizeRolledBuffers
  • Replaced excludedLabels with filtrationMode and filtrationLabels