Open rhavlick opened 6 years ago
public static void Run(TimerInfo myTimer, Microsoft.Extensions.Logging.ILogger logger)
{
var log = new LoggerConfiguration().WriteTo.ILogger(logger).CreateLogger();
log.Information("Hello!");
}
Does that help?
Thanks Jon, sorry, I wasn't more descriptive, but is there a way to do something like:
public static void Run(TimerInfo myTimer, Microsoft.Extensions.Logging.ILogger logger) { var log = new LoggerConfiguration().WriteTo.ILogger(logger).CreateLogger(); logger.LogInformation("Hello!"); }
I would like to use the existing ILogger, but just have it write to SeriLog.
Thanks
Sorry, I don't understand; Serilog writes to the ILogger and any other sinks you provide. In my case I write to the ILogger so I can see the output in the console, and to Loggly.
This sink behaves in the same way as the TraceWriter sink: https://www.nuget.org/packages/Serilog.Sinks.AzureWebJobsTraceWriter
I think he wants to do the same as me, use ILogger, but use Serilog to customise how it outputs. I think the problem is that the ILogger isn't available when you setup Serilog in StartUp.
Hello,
Do you have an example of how this could be used in Azure Functions 2.0 where the ILogger is passed into the static function? (There is a lack of DI in Azure Functions 2.0 currently)
Thanks.