コード例 #1
0
        /// <summary>
        /// Loads the configuration from Xml.
        /// </summary>
        /// <param name="reader">An XmlReader containing your configuration data.</param>
        /// <returns>A new instance of a LoggingConfig object.</returns>
        public static LoggingConfig Load(XmlReader reader)
        {
            var result = new LoggingConfig();

            reader.GoToElement();

            if (!reader.IsEmptyElement)
            {
                result.MaxExceptionLength = null;   // assume no limit is intended if param is omitted

                reader.ReadStartElement();
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                    case "LogUnhandledExceptions":
                        result.LogUnhandledExceptions = Convert.ToBoolean(reader.ReadElementContentAsInt());
                        break;

                    case "PreventUnhandledExceptions":
                        result.PreventUnhandledExceptions = Convert.ToBoolean(reader.ReadElementContentAsInt());
                        break;

                    case "MaxExceptionLength":
                        result.MaxExceptionLength = reader.ReadElementContentAsInt();
                        break;

                    case "QueryStringParam":
                        result.QueryStringParam = reader.ReadElementContentAsString();
                        break;

                    default:
                        reader.Skip();
                        break;
                    }
                }
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }

            return(result);
        }
        /// <summary>
        /// Loads the configuration from Xml.
        /// </summary>
        /// <param name="reader">An XmlReader containing your configuration data.</param>
        /// <returns>A new instance of a LoggingConfig object.</returns>
        public static LoggingConfig Load(XmlReader reader)
        {
            var result = new LoggingConfig();

            reader.GoToElement();

            if (!reader.IsEmptyElement)
            {
                result.MaxExceptionLength = null;   // assume no limit is intended if param is omitted

                reader.ReadStartElement();
                while (reader.GoToSibling())
                {
                    switch (reader.LocalName)
                    {
                        case "LogUnhandledExceptions":
                            result.LogUnhandledExceptions = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "PreventUnhandledExceptions":
                            result.PreventUnhandledExceptions = Convert.ToBoolean(reader.ReadElementContentAsInt());
                            break;
                        case "MaxExceptionLength":
                            result.MaxExceptionLength = reader.ReadElementContentAsInt();
                            break;
                        case "QueryStringParam":
                            result.QueryStringParam = reader.ReadElementContentAsString();
                            break;
                        default:
                            reader.Skip();
                            break;
                    }
                }
                reader.ReadEndElement();
            }
            else
                reader.Skip();

            return result;
        }
コード例 #3
0
 public SMFLogger(DiagnosticsConfig diagConfig, LoggingConfig loggingConfig)
 {
     DiagConfig = diagConfig;
     healthMonitorLogger = new HealthMonitorLogger(loggingConfig);
 }
 public HealthMonitorLogger(LoggingConfig loggingConfig)
 {
     AdditionalLogData = new Dictionary<string, string>();
     LoggingService.Current.Configuration = loggingConfig;
 }