Postsharp 不登录跟踪级别

Postsharp does not log on trace level

我喜欢在跟踪级别上记录一些 Postsharp 消息。不幸的是,记录到这个级别没有输出。所有其他级别都在工作。与控制台或 NLog 后端或当我从其他 class.

登录时的行为相同

如何启用跟踪级别?

App.xaml.cs:

[Log(AttributeExclude = true)]
public partial class App
{
    private static readonly LogSource LogSource = LogSources.Default.ForCurrentType().WithLevels(LogLevel.Trace, LogLevel.Error);

    protected override void OnStartup(StartupEventArgs e)
    {
        LoggingServices.DefaultBackend = new PostSharp.Patterns.Diagnostics.Backends.Console.ConsoleLoggingBackend();
        LogSource.Debug.Write(Formatted("Debug"));      // prints "Debug"
        LogSource.Trace.Write(Formatted("Trace"));      // prints nothing
        LogSource.Default.Write(Formatted("Default"));  // prints nothing
        LogSource.Trace.IsEnabled                       // is false
        ..

GlobalAspect.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_*" )]

LogLevel.Trace 是 PostSharp 诊断库中的最低日志记录级别。默认情况下,日志记录后端的详细程度设置为 LogLevel.Debug,因此所有跟踪消息都将被忽略。您可以自定义日志记录后端的详细程度,如下例所示:

LoggingServices.DefaultBackend.DefaultVerbosity.SetMinimalLevel( LogLevel.Trace );