簡體   English   中英

以編程方式在nlog中使用規則排除特定記錄器

[英]Excluding specific loggers using a rule in nlog programmatically

我正在尋找一種以編程方式實現以下日志記錄規則的方法。

<logger name="Name.Space.*" minlevel="Debug" maxlevel="Error" final="true" /> 

我可以使用以下命令設置“ name ”和“ loglevel ”但是沒有辦法實現final =“true”..

LoggingRule fileLoggingRule = new LoggingRule("ConnDriverLogger", LogLevel.Trace, connDriverFileTarget);
connDriverLoggingConfig.LoggingRules.Add(fileLoggingRule);

有任何建議實施上述?

LoggingRule.Final屬性怎么樣?

在你的情況下:

LoggingRule fileLoggingRule = new LoggingRule("ConnDriverLogger", LogLevel.Trace, connDriverFileTarget);
fileLoggingRule.Final = true;
connDriverLoggingConfig.LoggingRules.Add(fileLoggingRule);

我在NLog的存儲庫中找到了LoggingRule.Final屬性:

https://github.com/NLog/NLog/blob/master/src/NLog/Config/LoggingRule.cs

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM