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.
精彩评论