You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingMicrosoft.Extensions.Logging;foreach(booluseJsonLoggerinnew[]{false,true}){usingILoggerFactoryloggerFactory=LoggerFactory.Create(
builder =>{if(useJsonLogger){builder.AddJsonConsole();}else{builder.AddConsole();}});varlogger=loggerFactory.CreateLogger("Logger");logger.LogValues(Enumerable.Range(1,5));}staticpartialclassLogger{[LoggerMessage(EventId=1,Level=LogLevel.Information,Message="Values are {Values}")]publicstaticpartialvoidLogValues(thisILoggerlogger,IEnumerable<int>values);}
Outputs:
info: Logger[1]
Values are 1, 2, 3, 4, 5
{"EventId":1,"LogLevel":"Information","Category":"Logger","Message":"Values are 1, 2, 3, 4, 5","State":{"Message":"Values are 1, 2, 3, 4, 5","Values":"System.Linq.Enumerable\u002BRangeIterator","{OriginalFormat}":"Values are {Values}"}}
The message contains the items of the enumerable (1, 2, 3, 4, 5) while the JSON State contains ToString of the enumerable: ("Values":"System.Linq.Enumerable\u002BRangeIterator").
The behavior I expect is for the JSON State to include the enumerable items in a JSON array ("Values": [1, 2, 3, 4, 5]).
The text was updated successfully, but these errors were encountered:
For example:
Outputs:
The message contains the items of the enumerable (
1, 2, 3, 4, 5
) while the JSONState
containsToString
of the enumerable: ("Values":"System.Linq.Enumerable\u002BRangeIterator"
).The behavior I expect is for the JSON
State
to include the enumerable items in a JSON array ("Values": [1, 2, 3, 4, 5]
).The text was updated successfully, but these errors were encountered: