You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MassTransit Mediator消费者异常未被日志记录的解决方法

根因说明

你观察到的MassTransit Mediator消费异常仅输出R-FAULT标记、无异常详情的问题,和MassTransit Mediator本身的配置逻辑无关,问题来源于项目依赖的aws-logging-dotnet包的默认行为:该包默认关闭了异常信息的输出开关,即使MassTransit已经将完整异常对象上报到日志上下文,也不会被序列化到最终日志中。

修复方案

修改日志配置,将IncludeException属性设置为true即可,参考配置如下:

"Logging": {
  "Region": "us-east-1",
  "LogGroup": "AspNetCore.WebSample",
  "IncludeLogLevel": true,
  "IncludeCategory": true,
  "IncludeNewline": true,
  "IncludeException": true,
  "IncludeEventId": false,
  "IncludeScopes": false,
  "LogLevel": {
    "Default": "Debug",
    "System": "Information",
    "Microsoft": "Information"
  }
}

配置生效后重启服务,消费者抛出异常时,日志会自动输出完整的异常消息、堆栈轨迹等详情。


内容的提问来源于stack exchange,提问作者Kevin Smith

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 12:24:03