I have a Azure Function that triggers when a new service bus message arrives. I want to use Serilog to show messages on my console and in MongoDB.
But, when i enable serilog in my azure function project, a lot of unecessary messages appears. I'm trying to supress this messages in host.json, but this dont't work.
This messages appears when the application starts:
[12:15:26 INF] Initializing Warmup Extension.
[12:15:26 INF] Initializing Host. OperationId: '9cfb7811-e411-4445-b58b-0c702124462e'.
[12:15:26 INF] Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=9cfb7811-e411-4445-b58b-0c702124462e
[12:15:26 INF] User profile is available. Using 'C:\Users\codew\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
[12:15:26 INF] LoggerFilterOptions
{
"MinLevel": "None",
"Rules": [
{
"ProviderName": null,
"CategoryName": null,
"LogLevel": null,
"Filter": "<AddFilter>b__0"
},
{
"ProviderName": "Serilog.Extensions.Logging.SerilogLoggerProvider",
"CategoryName": null,
"LogLevel": "Trace",
"Filter": null
},
{
"ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
"CategoryName": null,
"LogLevel": "None",
"Filter": null
},
{
"ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
"CategoryName": null,
"LogLevel": null,
"Filter": "<AddFilter>b__0"
},
{
"ProviderName": "Azure.Functions.Cli.Diagnostics.ColoredConsoleLoggerProvider",
"CategoryName": null,
"LogLevel": null,
"Filter": "<AddFilter>b__0"
}
]
}
[12:15:26 INF] LoggerFilterOptions
{
"MinLevel": "None",
"Rules": [
{
"ProviderName": null,
"CategoryName": null,
"LogLevel": null,
"Filter": "<AddFilter>b__0"
},
{
"ProviderName": "Serilog.Extensions.Logging.SerilogLoggerProvider",
"CategoryName": null,
"LogLevel": "Trace",
"Filter": null
},
{
"ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
"CategoryName": null,
"LogLevel": "None",
"Filter": null
},
{
"ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
"CategoryName": null,
"LogLevel": null,
"Filter": "<AddFilter>b__0"
},
{
"ProviderName": "Azure.Functions.Cli.Diagnostics.ColoredConsoleLoggerProvider",
"CategoryName": null,
"LogLevel": null,
"Filter": "<AddFilter>b__0"
}
]
}
[12:15:26 INF] ConcurrencyOptions
{
"DynamicConcurrencyEnabled": false,
"MaximumFunctionConcurrency": 500,
"CPUThreshold": 0.8,
"SnapshotPersistenceEnabled": true
}
[12:15:26 INF] FunctionResultAggregatorOptions
{
"BatchSize": 1000,
"FlushTimeout": "00:00:30",
"IsEnabled": true
}
[12:15:26 INF] SingletonOptions
{
"LockPeriod": "00:00:15",
"ListenerLockPeriod": "00:00:15",
"LockAcquisitionTimeout": "10675199.02:48:05.4775807",
"LockAcquisitionPollingInterval": "00:00:05",
"ListenerLockRecoveryPollingInterval": "00:01:00"
}
[12:15:26 INF] ServiceBusOptions
{
"ClientRetryOptions": {
"Mode": "Exponential",
"TryTimeout": "00:01:00",
"Delay": "00:00:00.8000000",
"MaxDelay": "00:01:00",
"MaxRetries": 3
},
"TransportType": "AmqpTcp",
"WebProxy": "",
"AutoCompleteMessages": true,
"PrefetchCount": 0,
"MaxAutoLockRenewalDuration": "00:05:00",
"MaxConcurrentCalls": 128,
"MaxConcurrentSessions": 8,
"MaxMessageBatchSize": 1000,
"SessionIdleTimeout": "",
"EnableCrossEntityTransactions": false
}
Then, this messages appear constantly:
This is my code to enable serilog:
private void AddSerilog(IFunctionsHostBuilder builder)
{
Logger logger = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.Console()
.CreateLogger();
builder.Services.AddLogging(logBuilder =>
{
logBuilder.AddSerilog(logger);
});
}
Thanks!