如何编写 Roslyn 代码分析器来防止不良的日志记录做法

问题描述

我想帮助防止我们的开发团队不使用我们的结构化日志设置。正确的登录方式(对我们来说)是这样的:

_logger.Loginformation("This is a message template with a {@StructuredField}",structuredFieldVariable);

错误的记录方式如下:

_logger.Loginformation($"this is a poorly constructed log message with a {variable} in the template");

我认为可以编写一个 roslyn 代码分析器来检查是否在 _logger.Loginformation() 内部进行了任何字符串插值。这可能/可行吗?

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)