Function App .Net 8 Isolated 환경에서 서버를 운영하고 있습니다.
Function class에서 ILogger를 주입받아 비즈니스 로직에서 로깅을 합니다.
ILogger를 아래와 같이 확장하여 사용자 정의 로깅을 했습니다.
[LoggerMessage(EventId = (int)LogEventId.Player, Level = LogLevel.Information, Message = "{AccountID} {Message}")]
public static partial void PlayerInformation(this ILogger logger, AccountID accountID, string message);
Hosting Setting시 ApplicationInsights를 추가하고 Filter를 초기화했습니다.
// Program.cs
var host = new HostBuilder()
.ConfigureFunctionsWebApplication((IFunctionsWorkerApplicationBuilder builder) =>
{
/* Middleware */
})
.ConfigureAppConfiguration((ctx, cfg) =>
{
/* App Config */
})
.ConfigureLogging((ctx, logging) =>
{
logging.AddApplicationInsights();
logging.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Information);
})
.ConfigureServices((ctx, services) =>
{
/* Service Config */
})
.Build();
host.Run();
host 설정의 sampling setting에서 Trace type을 예외로 추가했습니다.
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request;Exception;Trace"
}
}
}
}
Azure Portal에서 데이터를 100% 보존하도록 설정했습니다.

사용자의 Request가 성공적으로 처리되었고 반드시 수행되어야 하는 위치에 로깅 코드를 삽입했기에 로그는 반드시 남아야 합니다.
누락되는 로그에 특별한 규칙은 없어보입니다.
특정 EventId가 누락된다거나, severityLevel이 다르게 설정된다거나 하는 문제도 없습니다.
혹시 제가 놓친 부분이나 추가적으로 확인해야 하는 부분이 있을까요?