private void TraceMessagesUsingListener(FormattedAppInsightsTraceListener listener, LogEntry logEntry) { Assert.IsNotNull(listener); foreach (var categorySource in logEntry.Categories) { listener.TraceData(new TraceEventCache(), categorySource, logEntry.Severity, logEntry.EventId, logEntry); } }
public void LogByApplyingFilter() { var listener = new FormattedAppInsightsTraceListener(this.adapterHelper.InstrumentationKey, new TextFormatter("TEST{newline}TEST")) { Filter = new EventTypeFilter(SourceLevels.Information) }; listener.TelemetryClient = GetTelemetryClientWithCustomChannel(); listener.TraceData(new TraceEventCache(), "MockCateogry", TraceEventType.Error, 0, new LogEntry("message", "MockCateogry", 0, 0, TraceEventType.Error, "title", null)); Assert.AreEqual(true, this.adapterHelper.Channel.SentItems.Length == 1); }