示例#1
0
        /// <summary>
        /// Checks whether any error during XML configuration parsing has occured.
        /// If there are any and <c>ThrowConfigExceptions</c> or <c>ThrowExceptions</c>
        /// setting is enabled - throws <c>NLogConfigurationException</c>, otherwise
        /// just write an internal log at Warn level.
        /// </summary>
        /// <param name="rootContentElement">Root NLog configuration xml element</param>
        private void CheckParsingErrors(NLogXmlElement rootContentElement)
        {
            var parsingErrors = rootContentElement.GetParsingErrors().ToArray();

            if (parsingErrors.Any())
            {
                if (LogManager.ThrowConfigExceptions ?? LogManager.ThrowExceptions)
                {
                    string exceptionMessage = string.Join(Environment.NewLine, parsingErrors);
                    throw new NLogConfigurationException(exceptionMessage);
                }
                else
                {
                    foreach (var parsingError in parsingErrors)
                    {
                        InternalLogger.Log(LogLevel.Warn, parsingError);
                    }
                }
            }
        }
示例#2
0
 /// <summary>
 /// Checks whether any error during XML configuration parsing has occured.
 /// If there are any and <c>ThrowConfigExceptions</c> or <c>ThrowExceptions</c>
 /// setting is enabled - throws <c>NLogConfigurationException</c>, otherwise
 /// just write an internal log at Warn level.
 /// </summary>
 /// <param name="rootContentElement">Root NLog configuration xml element</param>
 private void CheckParsingErrors(NLogXmlElement rootContentElement)
 {
     var parsingErrors = rootContentElement.GetParsingErrors().ToArray();
     if(parsingErrors.Any())
     {
         if (LogManager.ThrowConfigExceptions ?? LogManager.ThrowExceptions)
         {
             string exceptionMessage = string.Join(Environment.NewLine, parsingErrors);
             throw new NLogConfigurationException(exceptionMessage);
         }
         else
         {
             foreach (var parsingError in parsingErrors)
             {
                 InternalLogger.Log(LogLevel.Warn, parsingError);
             }
         }
     }
 }