2013-03-17 106 views
4

我正在尋找一種以編程方式實現以下記錄規則的方法。以編程方式排除在nlog中使用規則的特定記錄器

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

我可以使用以下方法來設置「」 &「日誌級別」,但也沒有辦法來實現最終的=「真正的」 ..

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

任何建議執行以上?

回答

5

LoggingRule.Final屬性如何?

你的情況:

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

我發現LoggingRule.Final財產在這裏NLOG的存儲庫:

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

+0

在downvote沒有評論?我的回答有問題嗎? – wageoghe 2014-03-18 17:23:02

+0

沒問題。我編輯了答案(在NLog的倉庫中添加「),所以你可以嘗試刪除投票,如果你願意的話。 – wageoghe 2014-03-19 21:31:38