通过Postsharp记录ASP网络核心API

时间:2020-02-25 06:09:25

标签: c# asp.net-core logging postsharp loupe

我正在使用Postsharp实现基于AOP的日志记录。我正在关注https://doc.postsharp.net/add-logging,但这并不能囊括所有信息。到目前为止,这是我使用loupe和来使用Postsharp的工作。[Loupe捕获信息没有任何问题,但是Postsharp的详细日志记录不起作用]

GlobalASpects.cs

using PostSharp.Patterns.Diagnostics;
using PostSharp.Extensibility;

[assembly: Log(AttributePriority = 1, AttributeTargetMemberAttributes = MulticastAttributes.Protected | MulticastAttributes.Internal | MulticastAttributes.Public)]
[assembly: Log(AttributePriority = 2, AttributeExclude = true, AttributeTargetMembers = "get_*" )]

Program.cs

enter image description here

然后我有带有示例代码的常规TestController只是为了测试代码。如果我看着Loupe,它会默认记录一些信息*(即使我删除了postharp特定代码,它也会记录一些信息)*

enter image description here

这里的问题是如何使它适用于ASP.net核心webapi,或者默认的postharp日志记录缺少什么?

0 个答案:

没有答案