private Logger CreateTargetWithGivenInstrumentationKey(
            string instrumentationKey = "TEST",
            Action<Logger> loggerAction = null,
            ApplicationInsightsTarget target = null)
        {
            // Mock channel to validate that our appender is trying to send logs
            TelemetryConfiguration.Active.TelemetryChannel = this.adapterHelper.Channel;

            if (target == null)
            {
                target = new ApplicationInsightsTarget();
            }

            target.InstrumentationKey = instrumentationKey;
            LoggingRule rule = new LoggingRule("*", LogLevel.Trace, target);
            LoggingConfiguration config = new LoggingConfiguration();
            config.AddTarget("AITarget", target);
            config.LoggingRules.Add(rule);

            LogManager.Configuration = config;
            Logger aiLogger = LogManager.GetLogger("AITarget");

            if (loggerAction != null)
            {
                loggerAction(aiLogger);
                target.Dispose();
                return null;
            }

            return aiLogger;
        }
        public void TraceMessageCanBeFormedUsingLayout()
        {
            ApplicationInsightsTarget target = new ApplicationInsightsTarget();
            target.Layout = @"${uppercase:${level}} ${message}";

            Logger aiLogger = this.CreateTargetWithGivenInstrumentationKey("test", null, target);

            aiLogger.Debug("Message");

            var telemetry = (TraceTelemetry)this.adapterHelper.Channel.SentItems.FirstOrDefault();
            Assert.IsNotNull(telemetry, "Didn't get the log event from the channel");

            Assert.AreEqual("DEBUG Message", telemetry.Message);
        }