brian enno
brian enno

Reputation: 462

Log Application Insight custom dimensions using serilog

I would like to enrich the serilog trace message with some customized information (for example the user role, the business solution..) and I would like to see those properties into the Application Insight "Custom Dimension" field. I tried to look around but I didn't find a proper solution. I'm using ASP.NET Core 3.1

Upvotes: 1

Views: 1832

Answers (1)

Tiny Wang
Tiny Wang

Reputation: 16076

As op said in the comment, there is a suggestion on this case.

Basicly,when we use serilog with application insights, we usually set custom dimensions like this:

var position = new { Latitude = 25, Longitude = 134 }; 
var elapsedMs = 34; 
var numbers = new int[] { 1, 2, 3, 4 };  
Logger.Information("Processed {@Position} in {Elapsed:000} ms., str {str}, numbers: {numbers}", position, elapsedMs, "test", numbers);

Upvotes: 5

Related Questions