serilog - Dotnet 核心、JSNLog 和 Serilog 之间的不兼容

标签 serilog jsnlog .net-core

我尝试在结构化模式下将 JSNLog 与 Serilog 一起使用,如文档中所述: http://jsnlog.com/Documentation/HowTo/StructuredLogging

我在 startup.cs 中有以下代码

var jsnlogConfiguration = new JsnlogConfiguration 
{
serverSideMessageFormat = "[UserIp: %userHostAddress], [Url: %url], [Browser: %userAgent] %message"
};

app.UseApplicationInsightsRequestTelemetry()
    .UseApplicationInsightsExceptionTelemetry()
    .UseStaticFiles()
    .UseMvc(routes => { routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}"); })
    .UseJSNLog(new LoggingAdapter(loggerFactory), jsnlogConfiguration); // Javascript logging

在我的 project.json 中,我有以下配置:

"JSNLog.AspNetCore": "2.20.1",
    "Serilog": "2.3.0",
    "Serilog.Extensions.Logging": "1.2.0",
    "Serilog.Sinks.File": "3.1.0",
    "Serilog.Sinks.RollingFile": "3.1.0",
    "Serilog.Sinks.Literate": "2.0.0",
    "Serilog.Sinks.AzureTableStorage": "2.0.0",
    "Serilog.Settings.Configuration": "2.1.0",
    "Serilog.Enrichers.Environment": "2.1.0",
    "Serilog.Enrichers.Thread": "2.0.0"

当我尝试添加时 "JSNLog.Serilog": "2.20.1"在 project.json 文件中,我在编译时收到以下错误:

The type or namespace name 'LoggingAdapter' could not be found (are you missing a using directive or an assembly reference?)

有什么想法吗?

最佳答案

最新版本的 JSNLog 现在可以很好地与 .Net Core 配合使用。看一下: http://jsnlog.com/Documentation/DownloadInstall/ForAspNetCore https://github.com/mperdeck/jsnlog.AspNet5Demo

我是 JSNLog 的作者。

关于serilog - Dotnet 核心、JSNLog 和 Serilog 之间的不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40102448/

相关文章:

c# - 简单的Serilog + ElasticSearch

c# - 有没有办法通过 appsettings.json 设置 Serilog 格式化程序变量?

c# - Serilog:记录不同类型的日志事件

json - Serilog/JSNLog .NET Core 记录空 JSON

javascript - 使用 ES6 导入 JSNLog 的正确语法是什么?

c# - 在 EF Core 中添加一对一关系时迁移数据?

c# - 从 Log4net 迁移到 .net Core 日志记录

email - Serilog 电子邮件接收器

c# - ASP.NET Core CRUD 工具 : command not found but actually installed