Sli*_*icc 5 c# azure .net-core
我在.net核心网络应用程序中使用App Insights,我可以在应用程序洞察日志中成功查看遥测数据.我现在希望能够推高自己的日志事件,但似乎无法使其工作(即我的自定义日志事件不会出现在应用洞察中).我的代码如下:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddApplicationInsights(app.ApplicationServices);
loggerFactory.AddDebug();
var logger = loggerFactory.CreateLogger<Startup>();
logger.LogInformation("I am a log event");
Run Code Online (Sandbox Code Playgroud)
我也尝试过显式设置日志级别,如:
loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Debug);
Run Code Online (Sandbox Code Playgroud)
但我从来没有在应用洞察中看到"我是一个日志事件"的文字.
谁能告诉我如何解决这个问题?
文档部分:在Application Insights中探索.NET跟踪日志
ALOS,您可以TelemetryClient直接使用.它有更多选项,不仅仅是TrackTrace记录器使用的选项.
// TelemetryClient telemetryClient = new Microsoft.ApplicationInsights.TelemetryClient(); ... telemetryClient.TrackEvent(""); telemetryClient.TrackMetric("",1); telemetryClient.TrackTrace("message",SeverityLevel.Information);
对于实例,您可以查看feature test int ApplicationInsights-aspnetcorerepo.
| 归档时间: |
|
| 查看次数: |
5137 次 |
| 最近记录: |