1
請考慮下面的代碼:全正在重置NLOG配置
public static void Main(string[] args)
{
// 1. At this point NLog will search for most common configuration locations,
// as described in http://nlog-project.org/wiki/Configuration_file.
var loggerOne = LogManager.GetLogger("LoggerOne");
// 2. We set NLog configuration to null, hoping that the next time the
// configuration is requested the whole process (1) will be repeated.
LogManager.Configuration = null;
// 3. NLog won't actually repeat process (1), and so logging is disabled for
// the following logger since the configuration is still null.
var loggerTwo = LogManager.GetLogger("LoggerTwo");
}
瀏覽NLOG的源代碼,很顯然,這與底層LogFactory
設定在true
在啓動configLoaded
領域做的,在將null
分配給Configuration
屬性(這對我來說最有意義)之後,未被重置爲false
。我的問題是我在這個過程中是否錯過了某些東西,或者是否確實如此(無需使用反射)來強制NLog從頭開始重新配置自身,並重復過程(1)
。