static Diagnostics()

in src/Common/Diagnostics.cs [21:56]


        static Diagnostics()
        {
            try
            {
                logger = LogManager.GetCurrentClassLogger();

                if (LogManager.Configuration?.LoggingRules?.Any() == true)
                {
                    // config file has been read, use that
                }
                else
                {
                    // no config file, use default config
                    string nlogConfigXml = ReadDefaultConfiguration();

                    SetDefaultConfiguration(nlogConfigXml);
                }
                
                string minLogLevel = Environment.GetEnvironmentVariable(MinLogLevelEnvironmentVariableName);

                if (!string.IsNullOrWhiteSpace(minLogLevel))
                {
                    // this will throw if invalid value
                    LogLevel minLogLevelParsed = LogLevel.FromString(minLogLevel);

                    LogManager.Configuration.LoggingRules.Single().SetLoggingLevels(minLogLevelParsed, LogLevel.Fatal);

                    LogManager.ReconfigExistingLoggers();
                }
            }
            catch (Exception)
            {
                // telemetry can never crash the application, swallow the exception
                // this probably means no logging
            }
        }