NLog: Why is a configuration variable required?

I find this cryptic and counter-intuitive:

Why does it work:

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

Until this is (EDIT: log files will not be written to the target file):

 LogManager.Configuration.LoggingRules.Add(rule); 

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

+4
source share
1 answer

I have not tested the code, but I suppose it has logic.

imho it should have been a method instead, or the configuration should not have been displayed at all.

+4
source

All Articles