Logentries + Xamarin = 怎么做?

Logentries + Xamarin = how?

主要问题是:如何在基于Xamarin的移动应用程序中集成Logentries?考虑以下两种方式:Serilog和log4net。

Logentries 支持 Android, iOS, WP natively but not when those APIs are proxified using Xamarin. Serilog is an elegant C# wrapper around Logentries API but there is a problem installing all of its needed components along with Xamarin's ones in the same project. Visual Studio is being used as IDE and NuGet as package manager. The packages that I think should be installed using NuGet in are Serilog, Serilog.Mobile, Serilog.Sinks.Logentries。 使用 Xamarin 创建 Android 应用程序时,正在使用 Mono.Android 模块。 Serilog 与 Mono.Android 完美共存,但 Serilog.Mobile 和 Serilog.Sinks.Logentries 不能:

Error: Could not install package 'Serilog.Sinks.Logentries 1.5.8'. You are trying to install this package into a project that targets 'Xamarin.iOS,Version=v1.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

错误消息与 Serilog.Mobile 相同。

当使用 Xamarin.iOS 时,唯一不兼容的模块恰好是 Serilog.Sinks.Logentries:

Error: Could not install package 'Serilog.Sinks.Logentries 1.5.8'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

看到有一个Xamarin Serilog "sink"。由创建 Logentries 的同一个人编写。据我所知,它只是移植 Serilog 库并为 Android 的日志 class 和 iOS' NSLog:

提供便利的记录器
ILogger androidLogger = new Serilog.LoggerConfiguration().WriteTo.AndroidLog().CreateLogger();
ILogger iosLogger = new Serilog.LoggerConfiguration().WriteTo.NSLog().CreateLogger();

所以第一个问题是,如果 Serilog 即将用于基于 Xamarin 的应用程序,那怎么会发生呢?

log4net 是 Logentries C# port but probably again not for Xamarin but for desktop applications. Just investigating it as well and as obvious there are some ports for iOS 的另一个选项。

如果您能向我推荐将 Logentries 与 Xamarin 结合使用的正确方法,那就太好了。

听起来您需要下载 Logentries 接收器的源代码并自行为 Xamarin 重新编译它。 (Serilog 对 Xamarin 平台的支持很少,因为无需购买许可证就很难获得 tools/running 构建。如果您可以对 https://github.com/serilog/serilog-sinks-logentries 存储库进行改进,那么无疑会欢迎启用 Xamarin 支持的 PR那里。)