![](/img/trans.png)
[英]Configure .Net Core 3 web API to always parse numbers with invariant Culture
[英]How to configure ApplicationInsightsTelemetry, in .NET Core Web Api
我正在尝试根据自己的喜好调整 Application Insights。 我有一些问题。 我是这样安装的。 在 startup.cs class 中:
public void ConfigureServices(IServiceCollection services)
{
services.AddApplicationInsightsTelemetry();
services.AddControllers();
}
在 Program.cs 中:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.AddApplicationInsights("73985d32-dc3b-4a7e-915e-aa7ef37fbef8");
logging.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Information);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
所以我避免使用 appsettings.json 配置,因为日志级别是可变的。 我的第一个问题是,如何通过查询数据库来制作动态日志级别? 另一个问题是如何添加自定义参数,键入 customer_name?
最后,我怎样才能让 Application Insights 注册我想要的值,使用: 只记录来自这些函数的值,例如,如果有异常,您不必注册它。
_logger.LogInformation("Test info");
_logger.LogError(ex, ex.Message);
关于你的第一个问题
我认为这是不可能的,有关更多详细信息,您可以查看bowman的答案。
关于第二个问题
Jitendra Patil 的代码真的很棒,这应该是你需要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.