admin管理员组文章数量:1123465
I'm trying to setup basic Application Insights logging based on host.json in a 8.0 isolated Azure function project. Below you can find the file I'm using.
{
"version": "2.0",
"logging": {
"fileLoggingMode": "debugOnly",
"logLevel": {
"Host.Aggregator": "Trace",
"Host.Results": "Trace",
"Function": "Trace",
"default": "Trace"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
},
"enableLiveMetricsFilters": true
}
}
}
I'm trying to activate AI logging in the builder code like this :
.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
// You will need extra configuration because above will only log per default Warning (default AI configuration) and above because of following line:
// .cs#L427
// This is documented here:
//
// So remove the default logger rule (warning and above). This will result that the default will be Information.
services.Configure<LoggerFilterOptions>(options =>
{
var toRemove = options.Rules.FirstOrDefault(rule => rule.ProviderName
== "Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider");
if (toRemove is not null)
{
options.Rules.Remove(toRemove);
}
//options.MinLevel = LogLevel.Trace;
});
When I look at the ILogger that is passed along in the azure function class constructor, it has :
- 2 providers : Microsoft.Azure.Functions.Worker.Logging.WorkerLoggerProvider and {Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider}
- No FilterOptions.Rules
- FilterOptions.MinLevel = Information
At least I would expect a MinLevel = Trace ... Am I missing something in my host.json file?
If I add options.MinLevel = LogLevel.Trace to my builder code, I do get MinLevel = Trace. But that's not the purpose, for our UAT & PROD environments we would like to set MinLevel = Information
Been looking around for post with similar approach but couldn't find it.
Regards, Sven
本文标签: Basic Azure function logging isn39t workingStack Overflow
版权声明:本文标题:Basic Azure function logging isn't working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736568054a1944732.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论