如何使用自己的索引从.NET Core Web API登录到Elasticsearch [英] How to log from .NET Core Web API into Elasticsearch on own index

查看:325
本文介绍了如何使用自己的索引从.NET Core Web API登录到Elasticsearch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 C# Elasticsearch 编写的.NET Web API.在Elasticsearch上,我有一个索引"日志记录",我要将日志从API推送到其中.

I have a .NET Web API written with C# and a Elasticsearch. On the Elasticsearch I have a index "logging" where I want to push my logs from the API into.

我无法弄清楚如何将C#API中的日志获取到Elastic"logging"中.我阅读了日志记录之类的文档使用ElasticSearch ... ,但是我的Elasticsearch上没有可用的logstash.因此,我正在寻找一个可以轻松记录日志的软件包.我认为需要交出登录"索引,以便它知道要登录的位置.

I can not figure out how to get my logs from the C# API into the Elastic "logging". I read documentations like Logging with ElasticSearch..., but I have no logstash available at my Elasticsearch. So I'm searching for a Package which helps my logging in a easy way. I think need to hand over the Index "logging" ones, so it knows where to log into.

有人可以为此推荐文档和/或软件包吗?

还是我需要自己编程?

推荐答案

Elasticsearch是仅"一个日志浏览器.为了浏览日志,您必须生成这些日志.

Elasticsearch is "just" a log browser. In order to browse your logs, you gonna have to generate those logs.

配置您的应用程序以使其例如与Serilog一起使用( https://stackify.com/serilog -tutorial-net-logging/).它将生成日志文件.

Configure you application to work with Serilog for instance (https://stackify.com/serilog-tutorial-net-logging/). It will generates the log files.

然后,将接收器配置为Elasticsearch( https://github.com/serilog/serilog-下沉弹性搜索).它将在elasticsearch可以读取的地方写入您的日志.

Then, configure a sink to Elasticsearch (https://github.com/serilog/serilog-sinks-elasticsearch). It will write your logs where elasticsearch can read it.

这篇关于如何使用自己的索引从.NET Core Web API登录到Elasticsearch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆