Search code examples
azure-functionsserilog-sinks-file

how to keep only application related logs and remove all other Function related logs


I an using Serilog with Azure Function app and all possible extra logs I set level either with warning or error,

 var logger = new LoggerConfiguration()
            .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
            .MinimumLevel.Override("Worker", LogEventLevel.Warning)
            .MinimumLevel.Override("Host", LogEventLevel.Warning)
            .MinimumLevel.Override("Host.Aggregator", LogEventLevel.Warning)
            .MinimumLevel.Override("Host.Results", LogEventLevel.Warning)
            .MinimumLevel.Override("System", LogEventLevel.Error)
            .MinimumLevel.Override("Function", LogEventLevel.Error)
            .MinimumLevel.Override("Azure.Storage.Blobs", LogEventLevel.Error)
            .MinimumLevel.Override("Azure.Core", LogEventLevel.Error)
            

This certainly minimize the logs data, but still I am seeing logs line which I don't want. I want only the application functionalities logs (2022-07-06 03:53:08.821 +00:00 [INF] my-test-SessionId=Order-5;Message:Message-0)

Is there any other settings I am missing? Thanks.

2022-07-06 03:53:08.816 +00:00 [INF]  my-queue-6b96259f-cb54-4ac7-9b20-2e4a695c539e: ReceiveBatchAsync start. MessageCount = 1

2022-07-06 03:53:08.819 +00:00 [INF]  my-queue-6b96259f-cb54-4ac7-9b20-2e4a695c539e: ReceiveBatchAsync done. Received '1' messages. LockTokens = <LockToken>05dc6848-50ea-4e81-afdd-62a838c0b4a9</LockToken>

2022-07-06 03:53:08.819 +00:00 [INF]  my-queue-e4de37f9-9b92-401a-8b9c-1212bc85011d: User message handler start: Message: SequenceNumber: 50275, LockToken: 05dc6848-50ea-4e81-afdd-62a838c0b4a9

2022-07-06 03:53:08.821 +00:00 [INF]  my-test-SessionId=Order-5;Message:Message-0

Solution

  • I'm guessing you need to add Azure.Storage.Queues as an override. In my case, I'm also using durable functions, which requires adding an override for DurableTask.