Dotnet核心,JSNLog和Serilog之间不兼容

时间:2016-10-18 07:45:48

标签: 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文件中,我在编译时收到以下错误:

  

类型或命名空间名称' LoggingAdapter'无法找到(是   你错过了使用指令或程序集引用?)

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

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

我是JSNLog的作者。