static private InitializeLog4NetAIAdapter ( string adapterComponentIdSnippet ) : void | ||
adapterComponentIdSnippet | string | |
Результат | void |
public void TracesAreEnqueuedInChannel() { TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; ApplicationInsightsAppenderTests.InitializeLog4NetAIAdapter(string.Empty); this.SendMessagesToMockChannel(this.adapterHelper.InstrumentationKey); }
public void InitializeAppenderDoesNotThrowLogExceptionWhenInstrumentationKeyIsCorrect() { string instrumentationKey = Guid.NewGuid().ToString(); this.VerifyInitializationSuccess( () => ApplicationInsightsAppenderTests.InitializeLog4NetAIAdapter(string.Format(InvariantCulture, @"<InstrumentationKey value=""{0}"" />", instrumentationKey)), instrumentationKey); }
public void TracesAreEnqueuedInChannel() { #pragma warning disable CS0618 // Type or member is obsolete TelemetryConfiguration.Active.InstrumentationKey = this.adapterHelper.InstrumentationKey; TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; #pragma warning restore CS0618 // Type or member is obsolete ApplicationInsightsAppenderTests.InitializeLog4NetAIAdapter(string.Empty); this.SendMessagesToMockChannel(this.adapterHelper.InstrumentationKey); }
public void InstrumentationKeyCanBeOverridden() { TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; // Set instrumentation key in Log4Net environment string instrumentationKey = "93d9c2b7-e633-4571-8520-d391511a1df5"; ApplicationInsightsAppenderTests.InitializeLog4NetAIAdapter(string.Format(@"<InstrumentationKey value=""{0}"" />", instrumentationKey)); Assert.AreNotEqual(instrumentationKey, this.adapterHelper.InstrumentationKey, "This test will not verify anything if the same instrumentation key is used by both"); this.SendMessagesToMockChannel(instrumentationKey); }
public AppendableLogger() { this.adapterHelper = new AdapterHelper(); // Mock channel to validate that our appender is trying to send logs TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; ApplicationInsightsAppenderTests.InitializeLog4NetAIAdapter(string.Empty); // Set up error handler to intercept exception var aiAppender = (ApplicationInsightsAppender)LogManager.GetRepository().GetAppenders()[0]; var errorHandler = new OnlyOnceErrorHandler(); aiAppender.ErrorHandler = errorHandler; this.Logger = LogManager.GetLogger("TestAIAppender"); }
public AppendableLogger() { this.adapterHelper = new AdapterHelper(); // Mock channel to validate that our appender is trying to send logs #pragma warning disable CS0618 // Type or member is obsolete TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel; #pragma warning restore CS0618 // Type or member is obsolete ApplicationInsightsAppenderTests.InitializeLog4NetAIAdapter(string.Empty); // Set up error handler to intercept exception var aiAppender = (ApplicationInsightsAppender)LogManager.GetRepository(callingAssembly).GetAppenders()[0]; var errorHandler = new OnlyOnceErrorHandler(); aiAppender.ErrorHandler = errorHandler; this.Logger = LogManager.GetLogger(callingAssembly, "TestAIAppender"); }
public void ValidateLoggingIsWorking() { string instrumentationKey = "93d9c2b7-e633-4571-8520-d391511a1df5"; ApplicationInsightsAppenderTests.InitializeLog4NetAIAdapter(string.Format(InvariantCulture, @"<InstrumentationKey value=""{0}"" />", instrumentationKey)); // Set up error handler to intercept exception ApplicationInsightsAppender aiAppender = (ApplicationInsightsAppender)log4net.LogManager.GetRepository(callingAssembly).GetAppenders()[0]; log4net.Util.OnlyOnceErrorHandler errorHandler = new log4net.Util.OnlyOnceErrorHandler(); aiAppender.ErrorHandler = errorHandler; // Log something ILog logger = log4net.LogManager.GetLogger(callingAssembly, "TestAIAppender"); for (int i = 0; i < 1500; i++) { logger.Debug("Trace Debug" + i + DateTime.Now); } Assert.AreEqual(instrumentationKey, aiAppender.TelemetryClient.Context.InstrumentationKey); Assert.IsNull(errorHandler.Exception); }
public void InitializeAppenderNotFailingWhenInstrumentionKeyIsEmptyString() { this.VerifyInitializationSuccess( () => ApplicationInsightsAppenderTests.InitializeLog4NetAIAdapter(@"<InstrumentationKey value="""" />"), string.Empty); }
public void Log4NetAddsCustomPropertiesToTraceTelemetry() { ApplicationInsightsAppenderTests.InitializeLog4NetAIAdapter(string.Empty); this.VerifyPropertiesInTelemetry(); }