How to control Nlog logLevel using environment variables

后端 未结 1 2038
醉话见心
醉话见心 2021-01-24 05:07

Trying to override LogLevel in Nlog Configuration using environment variable and it does not work: e.g



        
1条回答
  •  渐次进展
    2021-01-24 05:39

    I know this is a little more wordy, but maybe it works, until someone creates a proper fix:

     
              
                  
                  
                  
                  
                  
                    
     
    

    Btw. curious why your original question has it as less-than instead of greater-than. Would expect when having configured LOG_LEVEL to Warn, then it should log all warnings or worse.

    The above example will have a performance hit because lookup of environment-variables are not fast. NLog 4.6.8 introduces the cachedSeconds-features, that reduces the performance hit:

     
              
                  
                  
                  
                  
                  
              
     
    

    NLog 4.6.8 also makes it easier to use Layout in LoggingRules, but one is still required to make an explicit call to LogManager.ReconfigExistingLoggers() to activate.

    See also: https://github.com/nlog/NLog/wiki/Filtering-log-messages#semi-dynamic-routing-rules

    0 讨论(0)
提交回复
热议问题