I wrote an Azure function that is triggered every day at 4AM. I published it and it had its first successful run today at 4AM. I am sure that it ran successfully, because it put the expected data in the database.
[FunctionName("MyFunction")]
public async Task RunAsync([TimerTrigger("0 0 4 * * *")]TimerInfo myTimer, ILogger log)
{
// function body
}
I am using the log object to log information and error logs in the function body:
log.LogInformation("This is information log.");
// ...
log.LogError("This is error log.");
If I connect to the Log stream in Azure while the function runs, I see the logs. Where can I find them later? Only now I set the diagnostic setting to send FunctionAppLogs to Log Analytics workspace:
Will it resolve my issue?
Where can I see the details about executions (success/failure/time and maybe resource consumption) of my function? If I go to Function app, then choose functions, choose MyFunction from the list and go to the "Monitor" blade, I see only two failures (out of many!) from a few days ago. This failures were logged when the function was triggered via HTTP GET (now it's triggered by timer).
EDIT
This is the content of my hosts.json file:
{
"version": "2.0",
"logging": {
"fileLoggingMode": "always",
"applicationInsights": {
"samplingSettings": {
"isEnabled": true
}
},
"logLevel": {
"default": "Information",
"Host.Results": "Error",
"Function": "Error"
}
}
}
My understanding is that Application Insights should show some data (samplingSettings is enabled) and I should have the logs for my function (default is Information). I am unsure about the Function: Error setting only. In the documentation it is explained in the following way:
For logs of Host.Results or Function, only log events at Error or a higher level. ... For all other logs, including user logs, log only Information level and higher events.
Are the logs that I create in code "user logs" or "logs for Function"?


Where can i find them later?
Where can I see the details about executions?
Azure Functions creates an internal Application insight to monitor them, you can use a host.json file to configure log levels, sampling and so on.
host.json sample:
The aggregator indicates log flush time and limit number of executions to be logged. Azure functions use Adaptive Sampling for AI and the volume is adjusted automatically to keep within a specified maximum rate of traffic, and is controlled via the setting MaxTelemetryItemsPerSecond
To configure/disable Sampling in Azure functions for development environments you can manipulate host.json like this:
Change your loglevel to "trace" in your host.json.
Trace logs:
EDIT
Host.json:
ExcludedTypes node has been removed.
UPDATE: Function -> Functions -> click in your function -> Monitor -> configure AI