我的项目中有Common.Logging (3.4.1)和NLog (4.5.11)的最新版本。按照指示将Common.Logging与NLog绑定到app.config中,日志现在可以工作了。
现在我想要结构化日志记录:
private static readonly ILog _logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
var message = new IDontKnowWhat("A structured message for ClientId {ClientId}", ClientId.ToString());
_logger.Info(message);以上是伪代码,我不知道如何构造消息对象。而且,_logger.InfoFormat似乎使用String.Format,而不是结构化日志记录。
除了使用ThreadVariablesContext/GlobalVariablesContext/NestedThreadVariablesContext之外,Common.Logging还提供结构化日志记录吗?
发布于 2019-01-23 12:22:20
幸运的是,Common.Logging开发团队目前正在修复以下内容:支持结构化日志#176的Common.Logging.NLog45
发布于 2019-01-21 15:19:11
签出塞里罗格以进行结构化日志记录。如果您的需求是使用NLog,那么serilog也有一个NLog接收器。
https://stackoverflow.com/questions/54292580
复制相似问题