如何在Sentinel日志查看器的NLogViewerTarget上设置skipframes callsite

时间:2016-12-08 15:16:01

标签: c# nlog viewer

我有

var sentinalTarget = new NLogViewerTarget()
{
    Name = "sentinal",
    Address = "udp://127.0.0.1:9999",
    IncludeCallSite = true,
    IncludeSourceInfo = true
};

sentinalTarget.Parameters.Add(new NLogViewerParameterInfo() 
{   
    Name = "Callsite", 
    Layout = "${callsite:fileName=true:includeSourcePath=false:skipFrames=1}" 
});

var sentinalRule = new LoggingRule("*", LogLevel.Trace, sentinalTarget);
LogManager.Configuration.AddTarget("sentinal", sentinalTarget);
LogManager.Configuration.LoggingRules.Add(sentinalRule);

我需要在callsite上添加skipframe=1以查看调用NLog方法的实际类。

有办法吗?

1 个答案:

答案 0 :(得分:0)

如上所述,LogManager.AddHiddenAssembly(..)适用于这种情况:

示例:

LogManager.AddHiddenAssembly(typeof(LoggingExtensions).Assembly);

尽快调用此方法,例如main()app_start()