bri*_*nno 1 logging serilog azure-application-insights .net-5 asp.net-core-3.1
我想用一些自定义信息(例如用户角色、业务解决方案......)来丰富 serilog 跟踪消息,并且我希望在 Application Insight“自定义维度”字段中看到这些属性。我试图环顾四周,但没有找到合适的解决方案。我正在使用 ASP.NET Core 3.1
正如op在评论中所说,对这个案例有一个建议。
\n基本上\xef\xbc\x8c当我们使用serilog with application insights\xef\xbc\x8c时我们通常设置这样的自定义尺寸:
var position = new { Latitude = 25, Longitude = 134 }; \nvar elapsedMs = 34; \nvar numbers = new int[] { 1, 2, 3, 4 }; \nLogger.Information("Processed {@Position} in {Elapsed:000} ms., str {str}, numbers: {numbers}", position, elapsedMs, "test", numbers);\nRun Code Online (Sandbox Code Playgroud)\n