无法使用serilog接收器为Writesearch

时间:2017-07-21 09:21:08

标签: c# elasticsearch console-application serilog

我使用SeriLog 2.5.0和Serilogs.Sinks.ElasticSearch 5.3.0 nuget包将日志提取到ElasticSearch(它是一个控制台应用程序)。

我正在研究POC代码,以检查我是否能够将我的日志写入本地ElasticSearch实例。我正在按照以下教程

https://improveandrepeat.com/2014/10/elasticsearch-as-a-sink-for-serilog/

我无法使用以下代码,因为在WriteTo

中找不到ElasticSearch
Log.Logger = new LoggerConfiguration().WriteTo.ElasticSearch(new ElasticSearchSinkOptions()).CreateLogger();

可能已经使用此功能的人可以告诉我两个nuget软件包的版本是否有意义。我已经下载了所有最新的软件包。

1 个答案:

答案 0 :(得分:1)

以下是类似POC中使用的软件包列表

<?XML版本= “1.0” 编码= “UTF-8” &GT?; <封装> <封装ID = “Elasticsearch.Net” 版本= “5.5.0” targetFramework = “net462”/> <封装ID = “Microsoft.DotNet.InternalAbstractions” 版本= “1.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.Configuration” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.Configuration.Abstractions” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.Configuration.Binder” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.Configuration.FileExtensions” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.Configuration.Json” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.DependencyInjection” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.DependencyInjection.Abstractions” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.DependencyModel” 版本= “1.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.FileProviders.Abstractions” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.FileProviders.Physical” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.FileSystemGlobbing” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.Logging” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.Logging.Abstractions” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.Logging.Console” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.Logging.Debug” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.Options” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.Options.ConfigurationExtensions” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Microsoft.Extensions.Primitives” 版本= “2.0.0” targetFramework = “net462”/> <封装ID = “Newtonsoft.Json” 版本= “10.0.1” targetFramework = “net462”/> <封装ID = “Serilog” 版本= “2.5.0” targetFramework = “net462”/> <封装ID = “Serilog.Extensions.Logging” 版本= “2.0.2” targetFramework = “net462”/> <封装ID = “Serilog.Settings.Configuration” 版本= “2.4.0” targetFramework = “net462”/> <封装ID = “Serilog.Sinks.Elasticsearch” 版本= “5.4.0” targetFramework = “net462”/> <封装ID = “Serilog.Sinks.File” 版本= “3.2.0” targetFramework = “net462”/> <封装ID = “Serilog.Sinks.PeriodicBatching” 版本= “2.1.0” targetFramework = “net462”/> <封装ID = “Serilog.Sinks.RollingFile” 版本= “3.3.0” targetFramework = “net462”/> <封装ID = “System.Linq的” 版本= “4.1.0” targetFramework = “net462”/> <封装ID = “System.Resources.ResourceManager” 版本= “4.0.1” targetFramework = “net462”/> <封装ID = “System.Runtime” 版本= “4.1.0” targetFramework = “net462”/> <封装ID = “System.Runtime.CompilerServices.Unsafe” 版本= “4.4.0” targetFramework = “net462”/> < /包

看看这篇文章,它应该有所帮助,因为它完全专注于这个主题:

https://www.codeproject.com/Articles/1218350/Elasticsearch-Kibana-and-Docker-using-NET-Standard