コード例 #1
0
ファイル: LogSource.cs プロジェクト: wuyingyou/uniframework
		/// <summary>
		/// Initializes a new instance of the <see cref="LogSource"/> class with a name, a collection of <see cref="TraceListener"/>s and a level.
		/// </summary>
		/// <param name="name">The name for the instance.</param>
		/// <param name="traceListeners">The collection of <see cref="TraceListener"/>s.</param>
		/// <param name="level">The <see cref="SourceLevels"/> value.</param>
		public LogSource(string name, List<TraceListener> traceListeners, SourceLevels level)
		{
			this.name = name;
			this.traceListeners = traceListeners;
			this.level = level;
			this.instrumentationProvider = new LoggingInstrumentationProvider();
		}
コード例 #2
0
ファイル: WMITraceListener.cs プロジェクト: bnantz/NCS-V2-0
 /// <summary>
 /// Initializes a new instance of <see cref="WmiTraceListener"/> 
 /// </summary>
 public WmiTraceListener()
     : base()
 {
     instrumentationProvider = new LoggingInstrumentationProvider();
 }
コード例 #3
0
		/// <summary>
		/// Initalizes a new instance of <see cref="FormattedTraceListenerBase"/> with a <see cref="ILogFormatter"/>.
		/// </summary>
		/// <param name="formatter">The <see cref="ILogFormatter"/> to use when tracing a <see cref="LogEntry"/>.</param>
		public FormattedTraceListenerBase(ILogFormatter formatter)
		{
			this.Formatter = formatter;
			instrumentationProvider = new LoggingInstrumentationProvider();
		}
 public void Setup()
 {
     this.provider = new LoggingInstrumentationProvider(false, false, "application");
 }
コード例 #5
0
		/// <summary>
		/// Initalizes a new instance of <see cref="FormattedTraceListenerBase"/>.
		/// </summary>
		public FormattedTraceListenerBase()
		{
			instrumentationProvider = new LoggingInstrumentationProvider();
		}
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of <see cref="FormattedTextWriterTraceListener"/> with a <see cref="TextWriter"/>.
 /// </summary>
 /// <param name="writer">The writer to write to.</param>
 public FormattedTextWriterTraceListener(TextWriter writer)
     : base(writer)
 {
     instrumentationProvider = new LoggingInstrumentationProvider();
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of <see cref="FormattedTextWriterTraceListener"/> with a <see cref="Stream"/>.
 /// </summary>
 /// <param name="stream">The stream to write to.</param>
 public FormattedTextWriterTraceListener(Stream stream)
     : base(stream)
 {
     instrumentationProvider = new LoggingInstrumentationProvider();
 }
コード例 #8
0
 /// <summary>
 /// Initializes a new named instance of <see cref="FormattedTextWriterTraceListener"/> with a file name.
 /// </summary>
 /// <param name="fileName">The file name to write to.</param>
 /// <param name="name">The name.</param>
 public FormattedTextWriterTraceListener(string fileName, string name)
     : base(RootFileNameAndEnsureTargetFolderExists(fileName), name)
 {
     this.Formatter = formatter;
     instrumentationProvider = new LoggingInstrumentationProvider();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="RollingFormattedTextWriterTraceListener" /> class.
 /// </summary>
 /// <param name="fileName">Log filename</param>
 /// <param name="name">Log name.</param>
 public RollingFormattedTextWriterTraceListener(String fileName, String name)
     : base(RootFileNameAndEnsureTargetFolderExists(fileName), name)
 {
     mInstrumentationProvider = new LoggingInstrumentationProvider();
 }
コード例 #10
0
        public void EventLogWrittenWhenDeliveryToErrorSourceFails()
        {
            TraceListener badTraceListener = new BadTraceListener(new Exception("test exception"));
            LogSource badSource = new LogSource("badSource");
            badSource.Listeners.Add(badTraceListener);

            Dictionary<string, LogSource> logSources = new Dictionary<string, LogSource>();
            logSources.Add("foo", badSource);

            ILoggingInstrumentationProvider instrumentationProvider = new LoggingInstrumentationProvider(false, true, "applicationInstanceName");
            LogWriter writer = new LogWriterImpl(new List<ILogFilter>(), logSources, badSource, "foo", instrumentationProvider);

            writer.Write(CommonUtil.GetDefaultLogEntry());

            string lastEventLogEntry = CommonUtil.GetLastEventLogEntry();
            Assert.IsTrue(-1 != lastEventLogEntry.IndexOf("test exception"));
        }