作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在.net core 2.1.1中,使用以下方式注册应用程序见解:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddApplicationInsightsTelemetry(Configuration); //register InstrumentationKey
...
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
...
loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Information);
...
}
但是,当我将其包含在 .net core 2.2.0 中时,我收到警告:
'ApplicationInsightsLoggerFactoryExtensions.AddApplicationInsights(ILoggerFactory, IServiceProvider, LogLevel)' is obsolete: 'Use Microsoft.Extensions.Logging.ApplicationInsightsLoggingBuilderExtensions.AddApplicationInsights from Microsoft.Extensions.Logging.ApplicationInsights package'
我已经包含了包Microsoft.Extensions.Logging.ApplicationInsights包
并像这样使用:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
...
ApplicationInsightsLoggingBuilderExtensions.AddApplicationInsights(...//some params//);
...
}
这不允许我定义应用程序洞察的日志记录级别。 如何在 .net core 2.2.0 中定义日志记录级别?
最佳答案
请看一下这个article
如果是.net core web项目,可以使用以下代码在program.cs中设置日志级别:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureLogging(
builder =>
{
builder.AddApplicationInsights("app insights instrumentation key");
// You can set log level here
builder.AddFilter<Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider>
("", LogLevel.Information);
}
);
关于.net - 应用程序洞察 : loggerFactory. AddApplicationInsights 在 .net core 2.2.0 中已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55913933/
我是一名优秀的程序员,十分优秀!