1

I have gotten my serilog elastic search sink working. My problem now is I am looking for a way to override or remove the default out of the box fields naming convention when logs are posted to elastic search.

Sample in my code.

Log.Information("{sTest} {sName} , "This is test.", "This is my name");

The one that will be created will have something like fields.sTest, fields.sName

Is there a way to ommit the "fields." prefix and just use the sTest and the sName? Thank you.

Saeed Nasehi
  • 940
  • 1
  • 11
  • 27

1 Answers1

4

You need to set the InlineFields property to true.

var loggerConfig = new LoggerConfiguration()
    .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("http://localhost:9200"))
    {
        InlineFields = true,
        ...
    });
Kahbazi
  • 14,331
  • 3
  • 45
  • 76