I would like to know how I can use Serilog in Azure function. I have created a startup class in my function with the following setup:
var loggerConfiguration = new LoggerConfiguration()
.WriteTo.Console()
.CreateLogger();
builder.Services.AddLogging(op => op.AddSerilog(loggerConfiguration));
How do I inject the ILogger from serilog into my Function?
using Serilog;
namespace LogFunction
public class XX
{
[FunctionName("XX")]
public void Run([TimerTrigger("*/60 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.Information("Log this object {Car}", car); //using serilog not Microsoft.Extensions.Logging
}
}
As you can see above I am referencing the ILogger from Serilog and not Microsoft Logging.