Open waynebrantley opened 2 months ago
G'day Wayne - I think you want to ConfigureLogging()
(instead of adding Serilog directly to services
) in this case:
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddSerilog();
})
Nice to hear from you Nicholas. I tried the above and still so many items 'logged' to the console including errors and such when you do a basic 'broken' setup like described above. Not sure if this is isolated function thing or what. If you give it a shot you will see all the logs that are missed. There are like 5 total logs written through serilog - and probably 30 logs on the console output.
also there is not a AddSerilog((provider, loggerConfiguration) overload in this, so cannot do my normal thing
Hmm interesting --- any chance you can spot a difference between the messages that make it through the Serilog provider, and the ones that hit the console?
I'm unfortunately not familiar with Azure Functions; looks like previous similar questions on Stack Overflow have found some qualified eyes (https://stackoverflow.com/questions/71034036/how-to-setup-serilog-with-azure-functions-v4-correctly) - posting a question with some examples over there might be your best bet.
While I get serilog logs - no errors or anything from the host or providers (like SQL) do not go thru serilog. This is likely a azure function host limitation.
nothing that the function framework outputs ends up in serilog. This could be exceptions from any host extension like sqlTrigger.
Any injection of ILogger does work as expected.
Reproduction: ``func init
That gives you a base function project. Change program.cs to:
When you run it you will see lots of output on the console screen - and none of that ends up in seq (did not go through serilog).
Add a function to the project (and the Microsoft.Azure.Functions.Worker.Extensions.Sql package):
Run that and you will see lots more logs and errors about the connection string not being valid - again none of that is in seq.
There are logs in seq (going thru serilog) in the above example from Microsoft.AspNetCore.DataProtection and Microsoft.Hosting, etc - so that part of the serilog works - but anything from function app does not.
Not sure if this is an issue with logging not setup properly by AddSerilog or if this is an issue with https://github.com/Azure/azure-functions-host or https://github.com/Azure/azure-webjobs-sdk
Thoughts?