/// <summary>
        /// Initializes a new instance of the <see cref="RollingFlatFileTraceListener"/> class.
        /// </summary>
        /// <param name="fileName">The filename where the entries will be logged.</param>
        /// <param name="header">The header to add before logging an entry.</param>
        /// <param name="footer">The footer to add after logging an entry.</param>
        /// <param name="formatter">The formatter.</param>
        /// <param name="rollSizeKB">The maxium file size (KB) before rolling.</param>
        /// <param name="timeStampPattern">The date format that will be appended to the new roll file.</param>
        /// <param name="rollFileExistsBehavior">Expected behavior that will be used when the roll file has to be created.</param>
        /// <param name="rollInterval">The time interval that makes the file rolles.</param>
        /// <param name="maxArchivedFiles">The maximum number of archived files to keep.</param>
        public RollingFlatFileTraceListener(string fileName,
                                            string header = DefaultSeparator,
                                            string footer = DefaultSeparator,
                                            ILogFormatter formatter = null,
                                            int rollSizeKB = 0,
                                            string timeStampPattern = "yyyy-MM-dd",
                                            RollFileExistsBehavior rollFileExistsBehavior = RollFileExistsBehavior.Overwrite,
                                            RollInterval rollInterval = RollInterval.None,
                                            int maxArchivedFiles = 0)
            : base(fileName, header, footer, formatter)
        {
            Guard.ArgumentNotNullOrEmpty(fileName, "fileName");

            this.rollSizeInBytes = rollSizeKB * 1024;
            this.timeStampPattern = timeStampPattern;
            this.rollFileExistsBehavior = rollFileExistsBehavior;
            this.rollInterval = rollInterval;
            this.maxArchivedFiles = maxArchivedFiles;

            this.rollingHelper = new StreamWriterRollingHelper(this);

            if (rollInterval == RollInterval.Midnight)
            {
                var now = this.rollingHelper.DateTimeProvider.CurrentDateTime;
                var midnight = now.AddDays(1).Date;

                this.timer = new Timer((o) => this.rollingHelper.RollIfNecessary(), null, midnight.Subtract(now), TimeSpan.FromDays(1));
            }
        }
 public FlatFileListener(string fileName,
     string header = "----------------------------------",
     string footer = "----------------------------------",
     ILogFormatter formatter = null,
     int rollSizeKb = 20000,
     string timeStampPattern = "yyyy-MM-dd hh:mm:ss",
     RollFileExistsBehavior rollFileExistsBehavior = RollFileExistsBehavior.Increment,
     RollInterval rollInterval = RollInterval.Day,
     int maxArchivedFiles = 0)
     : base(Path.Combine(ResolveLogPath(), fileName), header, footer, formatter, rollSizeKb, timeStampPattern,
         rollFileExistsBehavior, rollInterval, maxArchivedFiles)
 {
 }
        /// <summary>
        /// Subscribes to an <see cref="IObservable{EventEntry}"/> using a <see cref="RollingFlatFileSink"/>.
        /// </summary>
        /// <param name="eventStream">The event stream. Typically this is an instance of <see cref="ObservableEventListener"/>.</param>
        /// <param name="fileName">The filename where the entries will be logged.</param>
        /// <param name="rollSizeKB">The maximum file size (KB) before rolling.</param>
        /// <param name="timestampPattern">The date format that will be appended to the new roll file.</param>
        /// <param name="rollFileExistsBehavior">Expected behavior that will be used when the roll file has to be created.</param>
        /// <param name="rollInterval">The time interval that makes the file to be rolled.</param>
        /// <param name="formatter">The formatter.</param>
        /// <param name="maxArchivedFiles">The maximum number of archived files to keep.</param>
        /// <param name="isAsync">Specifies if the writing should be done asynchronously, or synchronously with a blocking call.</param>
        /// <returns>A subscription to the sink that can be disposed to unsubscribe the sink and dispose it, or to get access to the sink instance.</returns>
        public static SinkSubscription<RollingFlatFileSink> LogToRollingFlatFile(this IObservable<EventEntry> eventStream, string fileName, int rollSizeKB, string timestampPattern, RollFileExistsBehavior rollFileExistsBehavior, RollInterval rollInterval, IEventTextFormatter formatter = null, int maxArchivedFiles = 0, bool isAsync = false)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                fileName = FileUtil.CreateRandomFileName();
            }

            var sink = new RollingFlatFileSink(fileName, rollSizeKB, timestampPattern, rollFileExistsBehavior, rollInterval, maxArchivedFiles, isAsync);

            var subscription = eventStream.SubscribeWithFormatter(formatter ?? new EventTextFormatter(), sink);

            return new SinkSubscription<RollingFlatFileSink>(subscription, sink);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RollingXmlTraceListenerData"/> class.
 /// </summary>
 /// <param name="name">The name for the configuration object.</param>
 /// <param name="traceOutputOptions">The trace options.</param>
 /// <param name="fileName"></param>
 /// <param name="rollSizeKB"></param>
 /// <param name="timeStampPattern"></param>
 /// <param name="rollFileExistsBehavior"></param>
 /// <param name="rollInterval"></param>
 public RollingXmlTraceListenerData(string name,
                                         string fileName,
                                         int rollSizeKB,
                                         string timeStampPattern,
                                         RollFileExistsBehavior rollFileExistsBehavior,
                                         RollInterval rollInterval,
                                         TraceOptions traceOutputOptions)
     : base(name, typeof(RollingXmlTraceListener), traceOutputOptions)
 {
     FileName = fileName;
     RollSizeKB = rollSizeKB;
     RollFileExistsBehavior = rollFileExistsBehavior;
     RollInterval = rollInterval;
     TimeStampPattern = timeStampPattern;
 }
		/// <summary>
		/// Initializes a new instance of <see cref="RollingFlatFileTraceListener"/> 
		/// </summary>
		/// <param name="fileName">The filename where the entries will be logged.</param>
		/// <param name="header">The header to add before logging an entry.</param>
		/// <param name="footer">The footer to add after logging an entry.</param>
		/// <param name="formatter">The formatter.</param>
		/// <param name="rollSizeKB">The maxium file size (KB) before rolling.</param>
		/// <param name="timeStampPattern">The date format that will be appended to the new roll file.</param>
		/// <param name="rollFileExistsBehavior">Expected behavior that will be used when the rool file has to be created.</param>
		/// <param name="rollInterval">The time interval that makes the file rolles.</param>
		public RollingFlatFileTraceListener(string fileName,
			string header,
			string footer,
			ILogFormatter formatter,
			int rollSizeKB,
			string timeStampPattern,
			RollFileExistsBehavior rollFileExistsBehavior,
			RollInterval rollInterval)
			: base(fileName, header, footer, formatter)
		{
			this.rollSizeInBytes = rollSizeKB * 1024;
			this.timeStampPattern = timeStampPattern;
			this.rollFileExistsBehavior = rollFileExistsBehavior;
			this.rollInterval = rollInterval;

			this.rollingHelper = new StreamWriterRollingHelper(this);
		}
        public RollingXmlTraceListener(
                string fileName,
                int rollSizeKB,
                string timeStampPattern,
                RollFileExistsBehavior rollFileExistsBehavior,
                RollInterval rollInterval,
                int maxArchivedFiles)
            : base(fileName)
        {
            this.rollSizeInBytes = rollSizeKB * 1024;
            this.timeStampPattern = timeStampPattern;
            this.rollFileExistsBehavior = rollFileExistsBehavior;
            this.rollInterval = rollInterval;
            this.maxArchivedFiles = maxArchivedFiles;

            this.rollingHelper = new StreamWriterRollingHelper(this);
        }
 /// <summary>
 /// Initializes a new instance of <see cref="RollingFlatFileTraceListener"/> 
 /// </summary>
 /// <param name="fileName">The filename where the entries will be logged.</param>
 /// <param name="header">The header to add before logging an entry.</param>
 /// <param name="footer">The footer to add after logging an entry.</param>
 /// <param name="formatter">The formatter.</param>
 /// <param name="rollSizeKB">The maxium file size (KB) before rolling.</param>
 /// <param name="timeStampPattern">The date format that will be appended to the new roll file.</param>
 /// <param name="rollFileExistsBehavior">Expected behavior that will be used when the roll file has to be created.</param>
 /// <param name="rollInterval">The time interval that makes the file rolles.</param>
 public RollingFlatFileTraceListener(
     string fileName,
     string header,
     string footer,
     ILogFormatter formatter,
     int rollSizeKB,
     string timeStampPattern,
     RollFileExistsBehavior rollFileExistsBehavior,
     RollInterval rollInterval)
     : this(fileName,
         header,
         footer,
         formatter,
         rollSizeKB,
         timeStampPattern,
         rollFileExistsBehavior,
         rollInterval,
         0)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RollingFlatFileTraceListenerData"/> class.
 /// </summary>
 /// <param name="name">The name for the configuration object.</param>
 /// <param name="traceOutputOptions">The trace options.</param>
 /// <param name="fileName"></param>
 /// <param name="footer"></param>
 /// <param name="header"></param>
 /// <param name="rollSizeKB"></param>
 /// <param name="timeStampPattern"></param>
 /// <param name="rollFileExistsBehavior"></param>
 /// <param name="rollInterval"></param>
 /// <param name="formatter"></param>
 public RollingFlatFileTraceListenerData(string name,
                                         string fileName,
                                         string header,
                                         string footer,
                                         int rollSizeKB,
                                         string timeStampPattern,
                                         RollFileExistsBehavior rollFileExistsBehavior,
                                         RollInterval rollInterval,
                                         TraceOptions traceOutputOptions,
                                         string formatter)
     : base(name, typeof(RollingFlatFileTraceListener), traceOutputOptions)
 {
     FileName = fileName;
     Header = header;
     Footer = footer;
     RollSizeKB = rollSizeKB;
     RollFileExistsBehavior = rollFileExistsBehavior;
     RollInterval = rollInterval;
     TimeStampPattern = timeStampPattern;
     Formatter = formatter;
 }
Example #9
0
        public IObserver <EventEntry> CreateSink(XElement element)
        {
            Guard.ArgumentNotNull(element, "element");

            int rollSizeKB = (int?)element.Attribute("rollSizeKB") ?? default(int);
            RollFileExistsBehavior rollFileExistsBehavior = (RollFileExistsBehavior)Enum.Parse(typeof(RollFileExistsBehavior), (string)element.Attribute("rollFileExistsBehavior") ?? default(RollFileExistsBehavior).ToString());
            RollInterval           rollInterval           = (RollInterval)Enum.Parse(typeof(RollInterval), (string)element.Attribute("rollInterval") ?? default(RollInterval).ToString());
            int maxArchivedFiles = (int?)element.Attribute("maxArchivedFiles") ?? default(int);

            var subject = new EventEntrySubject();

            subject.LogToRollingFlatFile(
                (string)element.Attribute("fileName"),
                rollSizeKB,
                (string)element.Attribute("timeStampPattern"),
                rollFileExistsBehavior,
                rollInterval,
                FormatterElementFactory.Get(element),
                maxArchivedFiles);

            return(subject);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RollingFlatFileTraceListenerData"/> class.
 /// </summary>
 /// <param name="name">The name for the configuration object.</param>
 /// <param name="traceOutputOptions">The trace options.</param>
 /// <param name="filter">The filter to apply.</param>
 /// <param name="fileName"></param>
 /// <param name="footer"></param>
 /// <param name="header"></param>
 /// <param name="rollSizeKB"></param>
 /// <param name="timeStampPattern"></param>
 /// <param name="rollFileExistsBehavior"></param>
 /// <param name="rollInterval"></param>
 /// <param name="formatter"></param>
 public RollingFlatFileTraceListenerData(string name,
                                         string fileName,
                                         string header,
                                         string footer,
                                         int rollSizeKB,
                                         string timeStampPattern,
                                         RollFileExistsBehavior rollFileExistsBehavior,
                                         RollInterval rollInterval,
                                         TraceOptions traceOutputOptions,
                                         string formatter,
                                         SourceLevels filter)
     : base(name, typeof(RollingFlatFileTraceListener), traceOutputOptions, filter)
 {
     FileName               = fileName;
     Header                 = header;
     Footer                 = footer;
     RollSizeKB             = rollSizeKB;
     RollFileExistsBehavior = rollFileExistsBehavior;
     RollInterval           = rollInterval;
     TimeStampPattern       = timeStampPattern;
     Formatter              = formatter;
 }
        public void RollingFlatFileTraceListenerNodeDataTest()
        {
            string name             = "some name";
            string fileName         = "some filename";
            string timesTampPattern = "yyyy-MM-dd";
            int    rollSizeKB       = 10;
            RollFileExistsBehavior rollFileExistsBehavior = RollFileExistsBehavior.Increment;
            RollInterval           rollInterval           = RollInterval.Hour;
            TraceOptions           traceOutputOptions     = TraceOptions.Callstack;
            SourceLevels           filter = SourceLevels.Critical;
            string header = "header";
            string footer = "footer";
            RollingFlatFileTraceListenerData rollingFlatFileTraceListenerData = new RollingFlatFileTraceListenerData();

            rollingFlatFileTraceListenerData.Name                   = name;
            rollingFlatFileTraceListenerData.FileName               = fileName;
            rollingFlatFileTraceListenerData.TimeStampPattern       = timesTampPattern;
            rollingFlatFileTraceListenerData.RollSizeKB             = rollSizeKB;
            rollingFlatFileTraceListenerData.RollFileExistsBehavior = rollFileExistsBehavior;
            rollingFlatFileTraceListenerData.RollInterval           = rollInterval;
            rollingFlatFileTraceListenerData.TraceOutputOptions     = traceOutputOptions;
            rollingFlatFileTraceListenerData.Filter                 = filter;
            rollingFlatFileTraceListenerData.Header                 = header;
            rollingFlatFileTraceListenerData.Footer                 = footer;
            RollingTraceListenerNode rollingFlatFileTraceListenerNode = new RollingTraceListenerNode(rollingFlatFileTraceListenerData);

            ApplicationNode.AddNode(rollingFlatFileTraceListenerNode);
            Assert.AreEqual(name, rollingFlatFileTraceListenerNode.Name);
            Assert.AreEqual(fileName, rollingFlatFileTraceListenerNode.FileName);
            Assert.AreEqual(timesTampPattern, rollingFlatFileTraceListenerNode.TimeStampPattern);
            Assert.AreEqual(rollSizeKB, rollingFlatFileTraceListenerNode.RollSizeKB);
            Assert.AreEqual(rollFileExistsBehavior, rollingFlatFileTraceListenerNode.RollFileExistsBehavior);
            Assert.AreEqual(rollInterval, rollingFlatFileTraceListenerNode.RollInterval);
            Assert.AreEqual(traceOutputOptions, rollingFlatFileTraceListenerNode.TraceOutputOptions);
            Assert.AreEqual(filter, rollingFlatFileTraceListenerNode.Filter);
            Assert.AreEqual(header, rollingFlatFileTraceListenerNode.Header);
            Assert.AreEqual(footer, rollingFlatFileTraceListenerNode.Footer);
        }
Example #12
0
        /// <summary>
        /// Subscribes to an <see cref="IObservable{EventEntry}"/> using a <see cref="RollingFlatFileSink"/>.
        /// </summary>
        /// <param name="eventStream">The event stream. Typically this is an instance of <see cref="ObservableEventListener"/>.</param>
        /// <param name="fileName">The filename where the entries will be logged.</param>
        /// <param name="rollSizeKB">The maximum file size (KB) before rolling.</param>
        /// <param name="timestampPattern">The date format that will be appended to the new roll file.</param>
        /// <param name="rollFileExistsBehavior">Expected behavior that will be used when the roll file has to be created.</param>
        /// <param name="rollInterval">The time interval that makes the file to be rolled.</param>
        /// <param name="formatter">The formatter.</param>
        /// <param name="maxArchivedFiles">The maximum number of archived files to keep.</param>
        /// <param name="isAsync">Specifies if the writing should be done asynchronously, or synchronously with a blocking call.</param>
        /// <returns>A subscription to the sink that can be disposed to unsubscribe the sink and dispose it, or to get access to the sink instance.</returns>
        public static SinkSubscription <RollingFlatFileSink> LogToRollingFlatFile(this IObservable <EventEntry> eventStream, string fileName, int rollSizeKB, string timestampPattern, RollFileExistsBehavior rollFileExistsBehavior, RollInterval rollInterval, IEventTextFormatter formatter = null, int maxArchivedFiles = 0, bool isAsync = false)
        {
            if (string.IsNullOrWhiteSpace(fileName))
            {
                fileName = FileUtil.CreateRandomFileName();
            }

            var sink = new RollingFlatFileSink(fileName, rollSizeKB, timestampPattern, rollFileExistsBehavior, rollInterval, maxArchivedFiles, isAsync);

            var subscription = eventStream.SubscribeWithFormatter(formatter ?? new EventTextFormatter(), sink);

            return(new SinkSubscription <RollingFlatFileSink>(subscription, sink));
        }
Example #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RollingFlatFileSink"/> class with the specified values.
        /// </summary>
        /// <param name="fileName">The filename where the entries will be logged.</param>
        /// <param name="rollSizeKB">The maximum file size (KB) before rolling.</param>
        /// <param name="timestampPattern">The date format that will be appended to the new roll file.</param>
        /// <param name="rollFileExistsBehavior">Expected behavior that will be used when the roll file has to be created.</param>
        /// <param name="rollInterval">The time interval that makes the file to be rolled.</param>
        /// <param name="maxArchivedFiles">The maximum number of archived files to keep.</param>
        /// <param name="isAsync">Specifies if the writing should be done asynchronously, or synchronously with a blocking call.</param>
        public RollingFlatFileSink(string fileName, int rollSizeKB, string timestampPattern, RollFileExistsBehavior rollFileExistsBehavior, RollInterval rollInterval, int maxArchivedFiles, bool isAsync)
        {
            this.file = FileUtil.ProcessFileNameForLogging(fileName);

            if (rollInterval == RollInterval.None)
            {
                if (!string.IsNullOrWhiteSpace(timestampPattern))
                {
                    Guard.ValidateTimestampPattern(timestampPattern, "timestampPattern");
                }
            }
            else
            {
                Guard.ValidateTimestampPattern(timestampPattern, "timestampPattern");
            }

            this.writer = new TallyKeepingFileStreamWriter(this.file.Open(FileMode.Append, FileAccess.Write, FileShare.Read));

            this.rollSizeInBytes        = rollSizeKB * 1024L;
            this.timestampPattern       = timestampPattern;
            this.rollFileExistsBehavior = rollFileExistsBehavior;
            this.rollInterval           = rollInterval;
            this.maxArchivedFiles       = maxArchivedFiles;
            this.isAsync = isAsync;

            this.rollingHelper = new StreamWriterRollingHelper(this);

            if (rollInterval == RollInterval.Midnight && !isAsync)
            {
                var now      = this.rollingHelper.DateTimeProvider.CurrentDateTime;
                var midnight = now.AddDays(1).Date;

                var callback = new TimerCallback(delegate(object o)
                {
                    lock (this.lockObject)
                    {
                        this.rollingHelper.RollIfNecessary();
                    }
                });

                this.timer = new Timer(callback, null, midnight.Subtract(now), TimeSpan.FromDays(1));
            }

            this.flushSource.SetResult(true);
            if (isAsync)
            {
                this.cancellationTokenSource = new CancellationTokenSource();
                this.pendingEntries          = new BlockingCollection <string>();
                this.asyncProcessorTask      = Task.Factory.StartNew((Action)this.WriteEntries, TaskCreationOptions.LongRunning);
            }
        }
Example #14
0
 public OperationTraceListener(string fileName, string header, string footer, ILogFormatter formatter,
                               int rollSizeKB, string timeStampPattern, RollFileExistsBehavior rollFileExistsBehavior,
                               RollInterval rollInterval) :
     base(fileName, header, footer, formatter, rollSizeKB, timeStampPattern, rollFileExistsBehavior, rollInterval)
 {
 }
 /// <summary>
 /// Creates an event listener that logs using a <see cref="RollingFlatFileSink"/>.
 /// </summary>
 /// <param name="fileName">The filename where the entries will be logged.</param>
 /// <param name="rollSizeKB">The maximum file size (KB) before rolling.</param>
 /// <param name="timestampPattern">The date format that will be appended to the new roll file.</param>
 /// <param name="rollFileExistsBehavior">Expected behavior that will be used when the roll file has to be created.</param>
 /// <param name="rollInterval">The time interval that makes the file to be rolled.</param>
 /// <param name="formatter">The formatter.</param>
 /// <param name="maxArchivedFiles">The maximum number of archived files to keep.</param>
 /// <param name="isAsync">Specifies if the writing should be done asynchronously, or synchronously with a blocking call.</param>
 /// <returns>An event listener that uses <see cref="RollingFlatFileSink"/> to log events.</returns>
 public static EventListener CreateListener(string fileName, int rollSizeKB, string timestampPattern, RollFileExistsBehavior rollFileExistsBehavior, RollInterval rollInterval, IEventTextFormatter formatter = null, int maxArchivedFiles = 0, bool isAsync = false)
 {
     var listener = new ObservableEventListener();
     listener.LogToRollingFlatFile(fileName, rollSizeKB, timestampPattern, rollFileExistsBehavior, rollInterval, formatter, maxArchivedFiles, isAsync);
     return listener;
 }
 public ILoggingConfigurationSendToRollingFileTraceListener RollEvery(RollInterval interval)
 {
     rollingTraceListenerData.RollInterval = interval;
     
     return this;
 }
Example #17
0
        /// <summary>
        /// Creates an event listener that logs using a <see cref="RollingFlatFileSink"/>.
        /// </summary>
        /// <param name="fileName">The filename where the entries will be logged.</param>
        /// <param name="rollSizeKB">The maximum file size (KB) before rolling.</param>
        /// <param name="timestampPattern">The date format that will be appended to the new roll file.</param>
        /// <param name="rollFileExistsBehavior">Expected behavior that will be used when the roll file has to be created.</param>
        /// <param name="rollInterval">The time interval that makes the file to be rolled.</param>
        /// <param name="formatter">The formatter.</param>
        /// <param name="maxArchivedFiles">The maximum number of archived files to keep.</param>
        /// <param name="isAsync">Specifies if the writing should be done asynchronously, or synchronously with a blocking call.</param>
        /// <returns>An event listener that uses <see cref="RollingFlatFileSink"/> to log events.</returns>
        public static EventListener CreateListener(string fileName, int rollSizeKB, string timestampPattern, RollFileExistsBehavior rollFileExistsBehavior, RollInterval rollInterval, IEventTextFormatter formatter = null, int maxArchivedFiles = 0, bool isAsync = false)
        {
            var listener = new ObservableEventListener();

            listener.LogToRollingFlatFile(fileName, rollSizeKB, timestampPattern, rollFileExistsBehavior, rollInterval, formatter, maxArchivedFiles, isAsync);
            return(listener);
        }
            public ILoggingConfigurationSendToRollingFileTraceListener RollEvery(RollInterval interval)
            {
                rollingTraceListenerData.RollInterval = interval;

                return(this);
            }
Example #19
0
        public void EntryIsWrittenWhenConfiguringLoggingWithRollingFile()
        {
            const string           FilePath         = "sample.log";
            const string           ListenerName     = "Rolling File Listener";
            const string           FormatterName    = "Text Formatter";
            const string           Template         = "My template";
            const string           Footer           = "Footer";
            const string           Header           = "Header";
            const int              RollAfterSize    = 150;
            const int              NumberFiles      = 5;
            const string           TimeStampPattern = "yyyymmdd";
            RollInterval           rollInterval     = RollInterval.Day;
            RollFileExistsBehavior behavior         = RollFileExistsBehavior.Increment;

            configurationStart.LogToCategoryNamed(CategoryName)
            .WithOptions
            .DoNotAutoFlushEntries()
            .SetAsDefaultCategory()
            .ToSourceLevels(SourceLevels.ActivityTracing)
            .SendTo
            .RollingFile(ListenerName)
            .RollEvery(rollInterval)
            .RollAfterSize(RollAfterSize)
            .CleanUpArchivedFilesWhenMoreThan(NumberFiles)
            .WhenRollFileExists(behavior)
            .UseTimeStampPattern(TimeStampPattern)
            .ToFile(FilePath)
            .WithFooter(Footer)
            .WithHeader(Header)
            .WithTraceOptions(TraceOptions.None)
            .FormatWith(new FormatterBuilder()
                        .TextFormatterNamed(FormatterName)
                        .UsingTemplate(Template));

            LoggingSettings settings = GetLoggingSettings();

            Assert.IsNotNull(settings);

            Assert.AreEqual(CategoryName, settings.DefaultCategory);
            Assert.AreEqual(1, settings.TraceSources.Count);

            var traceSource = settings.TraceSources.Get(0);

            Assert.IsFalse(traceSource.AutoFlush);
            Assert.AreEqual(SourceLevels.ActivityTracing, traceSource.DefaultLevel);
            Assert.AreEqual(ListenerName, traceSource.TraceListeners.Get(0).Name);
            Assert.AreEqual(1, settings.TraceListeners.Count);

            var rollingFile = settings.TraceListeners.Get(0) as RollingFlatFileTraceListenerData;

            Assert.IsNotNull(rollingFile);
            Assert.AreEqual(ListenerName, rollingFile.Name);
            Assert.AreEqual(behavior, rollingFile.RollFileExistsBehavior);
            Assert.AreEqual(rollInterval, rollingFile.RollInterval);
            Assert.AreEqual(RollAfterSize, rollingFile.RollSizeKB);
            Assert.AreEqual(TimeStampPattern, rollingFile.TimeStampPattern);
            Assert.AreEqual(NumberFiles, rollingFile.MaxArchivedFiles);
            Assert.AreEqual(FilePath, rollingFile.FileName);
            Assert.AreEqual(Footer, rollingFile.Footer);
            Assert.AreEqual(Header, rollingFile.Header);
            Assert.AreEqual(TraceOptions.None, rollingFile.TraceOutputOptions);
            Assert.AreEqual(FormatterName, rollingFile.Formatter);
            Assert.AreEqual(1, settings.Formatters.Count);

            var formatter = settings.Formatters.Get(FormatterName) as TextFormatterData;

            Assert.IsNotNull(formatter);
            Assert.AreEqual(Template, formatter.Template);
        }