2

如文档中所述,我尝试在结构化模式下将 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"

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

找不到类型或命名空间名称“LoggingAdapter”(您是否缺少 using 指令或程序集引用?)

任何想法?

4

1 回答 1

2

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

我是JSNLog的作者。

于 2017-06-18T03:19:45.440 回答