I am facing issues in logging messages from the service class of Azure Function app. There are no issues in logging from the function class. I followed the solution mentioned on Azure Functions - ILogger Logging across classes but cant figure out the issue.
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
},
"logLevel": {
"FunctionApp.Services.RestService": "Information"
}
}
}
RestService.cs
public class RestService : IRestService
{
private readonly ILogger<IRestService> _logger;
public RestService(ILogger<IRestService> logger)
{
_logger = logger;
}
public async Task<RestResponse> SampleMethod()
{
_logger.LogInformation("************************************TEST THIS WORK************************************","1212121212");
}
}
IRestService.cs
public interface IRestService
{
Task<RestResponse> SampleMethod(string url, string requestBody, string soapAction);
}
I am calling the RestService class from the function app.
Startup.cs
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddHttpClient();
builder.Services.AddSingleton<IRestService, RestService>();
}
}
As mentioned earlier, the log messages from the function class appears in App Insight but not from the service class. What am I missing?