'Azure V3 Function Logging into Another Class Library
I have an Azure function and I can successfully write logs from the app function but I want to use logger in another class library. I have done in DI and also added the necessary code but it does not log anything.
Azure function code is
Business data service code is
start up class code is. AddLoggin() is optional but it did not work with or without.
host.json file
I can see the logs written form the function app (MaterDataTimerTrigger) but I can't see anything written form the MasterDataBusinessService
Update: I changed the host.json file as per comments and it worked.
{
"version": "2.0",
"logging": {
"logLevel": {
"default": "Information"
}
}
}
Solution 1:[1]
From this Microsoft documentation --- The default value for all functions and telemetry categories is set to Warning (including Microsoft and Worker categories) so, by default, all errors and warnings generated by both, the runtime and custom logging, are gathered.
So to have information level, you should define the logLevel in host.json file.
"logging": {
"logLevel": {
"default": "Information"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
Also, I would suggest to set the samplingSettings to false so that all logs are logged at application insights instead of sampled one.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |




