/// <summary>
        /// Gets the optional boolean attribute value.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="attributeName">Name of the attribute.</param>
        /// <param name="defaultValue">Default value to return if the attribute is not found or if there is a parse error</param>
        /// <returns>Boolean attribute value or default.</returns>
        public static bool GetOptionalBooleanValue(this ILoggingConfigurationElement element, string attributeName,
                                                   bool defaultValue)
        {
            string value = element.GetOptionalValue(attributeName, null);

            if (string.IsNullOrEmpty(value))
            {
                return(defaultValue);
            }

            try
            {
                return(Convert.ToBoolean(value.Trim(), CultureInfo.InvariantCulture));
            }
            catch (Exception exception)
            {
                var configException = new NLogConfigurationException(exception, $"'{attributeName}' hasn't a valid boolean value '{value}'. {defaultValue} will be used");
                if (configException.MustBeRethrown())
                {
                    throw configException;
                }
                InternalLogger.Error(exception, configException.Message);
                return(defaultValue);
            }
        }
        public static string GetRequiredValue(this ILoggingConfigurationElement element, string attributeName, string section)
        {
            string value = element.GetOptionalValue(attributeName, null);

            if (value == null)
            {
                throw new NLogConfigurationException($"Expected {attributeName} on {element.Name} in {section}");
            }

            if (StringHelpers.IsNullOrWhiteSpace(value))
            {
                throw new NLogConfigurationException(
                          $"Expected non-empty {attributeName} on {element.Name} in {section}");
            }

            return(value);
        }
        public static string GetConfigItemTypeAttribute(this ILoggingConfigurationElement element, string sectionNameForRequiredValue = null)
        {
            var typeAttributeValue = sectionNameForRequiredValue != null?element.GetRequiredValue("type", sectionNameForRequiredValue) : element.GetOptionalValue("type", null);

            return(StripOptionalNamespacePrefix(typeAttributeValue)?.Trim());
        }