<p><strong>How do I send a structured message?</strong></p>

<p>If you want structured messages check out some of the recommended <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.2#third-party-logging-providers" rel="nofollow noreferrer">third party logging options</a>.  Some of these options have built-in support for Elasticsearch logging.  For instance, <a href="https://serilog.net" rel="nofollow noreferrer">Serilog</a> provides a <a href="https://github.com/serilog/serilog-sinks-elasticsearch" rel="nofollow noreferrer">"sink"</a> for putting logs directly into Elasticsearch.</p>

<p><strong>How do I configure it in code?</strong></p>

<p>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.</p>

<p><strong>How do I configure it for Elasticsearch?</strong></p>

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

CC BY-SA 4.0
2019-08-22T12:24:18.850Z
2019-08-22T12:24:18.850Z
Wesley Rolnick
<p>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".</p>

<p>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.</p>

CC BY-SA 4.0
2019-08-21T07:54:46.820Z
Its is very normal to ship plain old logs to ELK. Our apps have very ordinary logs typical of a webserver not json. So you don’t need to perform any conversion of logs. With respect to what writes to L of ELK or the F of EFK then that has to be something that is able to read the logs which entirely down to how and where you are running the code. You need to research how to integrate ELK or EFK into your environment.
simbo1905
<logging><elastic><json>
What software ihandles shipping to ElasticSearch the standard output of a .NET Core web application running in a container?
Mircea Ion
# What software ihandles shipping to ElasticSearch the standard output of a .NET Core web application running in a container?

(Asked by: username_0 on 2019-08-20)

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.

**Tags:** logging, elastic, json

> **Comments:**
> **username_1**: Its is very normal to ship plain old logs to ELK. Our apps have very ordinary logs typical of a webserver not json. So you don’t need to perform any conversion of logs. With respect to what writes to L of ELK or the F of EFK then that has to be something that is able to read the logs which entirely down to how and where you are running the code. You need to research how to integrate ELK or EFK into your environment.  

---

## 1 answers

### Answer by username_2 on 2019-08-22. Score: 1

**How do I send a structured message?**

If you want structured messages check out some of the recommended [third party logging options](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.2#third-party-logging-providers). Some of these options have built-in support for Elasticsearch logging. For instance, [Serilog](https://serilog.net) provides a ["sink"](https://github.com/serilog/serilog-sinks-elasticsearch) 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.


---

