Logger.InfoFormat 未使用 serilog 和 castle winsdor 日志记录第一个参数

Logger.InfoFormat not logging first parameter using serilog and castle winsdor log

我正在使用 Serilog 在控制台和 ElasticSearch 中记录我的请求和响应。

代码如下所示:

public class HttpLogDto
{
    public string Method { get; set; }
    public string Url { get; set; }
    public string QueryString { get; set; }
    public Dictionary<string, string[]> RequestHeaders { get; set; }
    public DateTime RequestedAt { get; set; }
    public string Request { get; set; }
    public Dictionary<string, string[]> ResponseHeaders { get; set; }
    public DateTime ResponsedAt { get; set; }
    public object Response { get; set; }
    public long ElapsedMilliseconds { get; set; }
}

public class RequestResponseLoggingMiddleware
{
    private readonly Castle.Core.Logging.ILogger _logger;
    public RequestResponseLoggingMiddleware(RequestDelegate next,Castle.Core.Logging.ILoggerFactory loggerFactory)
    {
        _next = next;
        _logger = loggerFactory.Create(typeof(RequestResponseLoggingMiddleware));
    }
    public async Task Invoke(HttpContext context)
    {
        HttpLogDto logDto = new logDto();
        //perform request and fill logDto

        _logger.InfoFormat("{\"Url\": {0},\"Method\": {1}, \"QueryString\": {2},\"RequestHeaders\": {3},\"RequestedAt\": {4} }", 
            new object[] {
                logDto.Url,
                logDto.Method,
                logDto.QueryString,
                logDto.RequestHeaders,
                logDto.RequestedAt});
    }
}

问题是,它从不填充第一个参数,输出日志是这样的:

我删除了文本前后的那两个大括号,这解决了问题。