// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory .AddAi(() => app.ApplicationServices.GetService <TelemetryClient>(), LogLevel.Trace) .AddDebug(LogLevel.Trace); app.UseApplicationInsightsTelemetryReplication( env.GetAppId(typeof(Startup)), new Uri(Configuration["ApplicationInsights:ProxyUri"], UriKind.Absolute)); app.UseApplicationInsightsRequestTelemetry(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseExceptionHandler(); } app.UseApplicationInsightsExceptionTelemetry(); app.Run(async(context) => { var client = context.RequestServices.GetService <TelemetryClient>(); client.TrackEvent("Hello World Event"); var logger = context.RequestServices.GetService <ILoggerFactory>().CreateLogger("SampleApp"); logger.LogInformation("Hello World Event by logger"); await context.Response.WriteAsync("Hello World!"); }); }