开发者

NLog : Why is a config variable mandatory?

开发者 https://www.devze.com 2023-02-27 04:14 出处:网络
I find this puzzling and counter-intuitive : Why this works : LoggingConfiguration config = LogManager.Configuration;

I find this puzzling and counter-intuitive :

Why this works :

LoggingConfiguration config = LogManager.Configuration;
config.LoggingRules.Add(rule);
LogManager.Configuration = config;

While this won't (EDIT : log files are 开发者_运维问答not written to target file):

LogManager.Configuration.LoggingRules.Add(rule);

It's funny to see how ready-to-use code snippets spread, while thorough explanations are so scarce


I haven't checked the code but I guess that the property setter has some logic in it.

imho it should had been a method instead, or the configuration shouldn't have been exposed at all.

0

精彩评论

暂无评论...
验证码 换一张
取 消