[英]PowerShell conversion of String into FileInfo automatically - What is this called?
[英]What method is called during Ilogger conversion of structured logging arguments to string?
我有一個 object 我想傳遞給日志記錄(默認內置日志記錄到控制台,不使用庫)作為這樣的參數:
logger.LogDebug("Executing MongoDB command: {Command}", command);
我所期望的是結果將是對command.ToString()
的調用,但此調用的結果與實際的ToString()
調用不同。
PS 有問題的BsonDocument
是來自 MongoDB 驅動程序的 BsonDocument,如果這有任何重要性的話。
PPS 我也與插值字符串結果進行了比較,結果有所不同(它似乎返回ToString()
,如我所料):
logger.LogDebug($"Executing MongoDB command: {command}");
默認格式化程序會將IEnumerable object 格式化為逗號分隔的字符串,您可以在此處找到源代碼:
https://source.dot.net/#Microsoft.Extensions.Logging.Abstractions/LogValuesFormatter.cs,229
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.