public ApplicationInsightsAppender SetupAiAppender(string appenderName, string instrumentationKey)
        {
            var hierarchyRoot = GetHierarchyRoot();

            RemoveAiAppender(appenderName);

            var patternLayout = new PatternLayout
            {
                ConversionPattern = "%message"
            };

            patternLayout.ActivateOptions();

            var aiAppender = new ApplicationInsightsAppender
            {
                Name = appenderName,
                InstrumentationKey = instrumentationKey,
                Layout             = patternLayout
            };

            aiAppender.ActivateOptions();

            hierarchyRoot.AddAppender(aiAppender);

            return(aiAppender);
        }
Esempio n. 2
0
        /// <summary>
        /// Creating Application Insights Appender
        /// </summary>
        /// <param name="TelemetryInstrumentationKey"></param>
        /// <param name="patternLayout"></param>
        private static IAppender CreateAIAppender(string TelemetryInstrumentationKey, PatternLayout patternLayout)
        {
            ApplicationInsightsAppender aIAppender = new ApplicationInsightsAppender();

            aIAppender.Name = "ApplicationInsightsAppender";
            aIAppender.InstrumentationKey = TelemetryInstrumentationKey;
            patternLayout.ActivateOptions();
            aIAppender.Layout = patternLayout;
            aIAppender.ActivateOptions();
            _aIAppender = aIAppender;

            return(aIAppender);
        }