1

I have a ballpark idea of how the ELK stack works. I read that by default, standard output is captured and that output will make its way to the Elasticsearch repository. If I post something to stdout, that content piece will be when visualized with Kibana in one field called "message".

So, besides the title which was anyway getting too long, here's the additional ask. How do I send a structured message, JSON I guess? How do I configure it? I read that it is possible, but I have some difficulties piecing it together. There's something about a JSON template that needs to be registered somewhere, but I lack a clear example.

Pierre.Vriens
  • 7,225
  • 14
  • 39
  • 84
Mircea Ion
  • 111
  • 1

1 Answers1

1

How do I send a structured message?

If you want structured messages check out some of the recommended third party logging options. Some of these options have built-in support for Elasticsearch logging. For instance, Serilog provides a "sink" for putting logs directly into Elasticsearch.

How do I configure it in code?

These options all tie into the ILogger interface, so testing different logging frameworks should require very little code changes. However, the initial entry point of the application (e.g. Program.cs) will need to be configured to use the 3rd party logger. The official .net core docs go over this in detail.

How do I configure it for Elasticsearch?

This will depend on the logger. The appsettings.json will most likely be where you configure the .net core application's connection to Elasticsearch.

Wesley Rolnick
  • 2,772
  • 12
  • 26