我尝试在结构化模式下将 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/