问题描述
我有一个.net核心控制台应用程序(不是AspNetCore),我想添加应用程序见解日志记录,以将跟踪日志推送到应用程序见解。我曾尝试使用Microsoft.ApplicationInsights.AspNetCore,但是当我这样做时:
I've got a .net core console application (not AspNetCore), and I want to add app insights logging that will push out the trace logs to app insights. I have tried using Microsoft.ApplicationInsights.AspNetCore, but when I do:
factory.AddApplicationInsights(serviceProvider);
它抛出一个错误,表示找不到托管环境
it throws an error saying it can't find the hosting environment
大概是因为这不是一个AspNetCore应用程序,而仅仅是一个纯控制台应用程序。
presumably because this is not an AspNetCore app, but just a pure console app.
是有没有办法可以将跟踪日志记录从.net核心控制台应用程序中推送到App Insights?
Is there a way I can get trace logging pushed to App Insights from within my .net core console app?
推荐答案
使用Microsoft.ApplicationInsights如。
Use Microsoft.ApplicationInsights as described in https://github.com/Microsoft/ApplicationInsights-aspnetcore/wiki/Getting-Started-for-a-.NET-Core-console-application.
这篇关于将应用程序见解跟踪日志记录添加到.net核心控制台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!