Пример #1
0
        /// <devdoc>
        /// Get a cloned instance of the formatter.
        /// </devdoc>
        /// <returns>An instance of the ILogFormatter.
        /// May return null if no format is specified and the default format does not exist.</returns>
        private ILogFormatter CreateFormatter(string formatterName)
        {
            ILogFormatter formatter     = null;
            FormatterData formatterData = null;

            if (formatterName != null && formatterName.Length > 0)
            {
                formatterData = loggingConfigurationView.GetFormatterData(formatterName);
            }
            // if the format isn't defined in the configuration settings
            if (formatterData == null)
            {
                // get the default format
                formatterData = loggingConfigurationView.GetDefaultFormatterData();

                // if the default format doesn't exist, log a warning in the event log
                if (formatterData == null)
                {
                    this.events.LogMissingDefaultFormatterError();
                }
            }
            if (formatterData != null)
            {
                LogFormatterFactory factory = new LogFormatterFactory(loggingConfigurationView.ConfigurationContext);
                formatter = factory.CreateFormatter(formatterData.Name);
            }
            return(formatter);
        }
Пример #2
0
        /// <devdoc>
        /// Get a cloned instance of the formatter.
        /// </devdoc>
        /// <returns>An instance of the ILogFormatter. 
        /// May return null if no format is specified and the default format does not exist.</returns>
        private ILogFormatter CreateFormatter(string formatterName)
        {
            ILogFormatter formatter = null;
            FormatterData formatterData = null;
            if (formatterName != null && formatterName.Length > 0)
            {
                formatterData = loggingConfigurationView.GetFormatterData(formatterName);
            }
            // if the format isn't defined in the configuration settings
            if (formatterData == null)
            {
                // get the default format
                formatterData = loggingConfigurationView.GetDefaultFormatterData();

                // if the default format doesn't exist, log a warning in the event log
                if (formatterData == null)
                {
                    this.events.LogMissingDefaultFormatterError();
                }
            }
            if (formatterData != null)
            {
                LogFormatterFactory factory = new LogFormatterFactory(loggingConfigurationView.ConfigurationContext);
                formatter = factory.CreateFormatter(formatterData.Name);
            }
            return formatter;
        }