Setting the logger via the azureFunction computation expression and then getting it with ctx.GetLogger() doesn't actually log anything.
How to reproduce:
Take the Saturn.Func sample from this repo and update the source code of SaturnFunc.fs and run the function app:
namespace MyFunctions
open Microsoft.AspNetCore.Http
open Microsoft.Azure.WebJobs.Host
open Saturn.AzureFunctions
open Microsoft.Extensions.Logging
open Giraffe
module Functions =
open Saturn
open Microsoft.Azure.WebJobs
let testCntl = controller {
index (fun ctx ->
// Get logger instance
let logger = ctx.GetLogger()
// This warning doesn't get logged
logger.LogWarning("logging doesn't work")
Controller.text ctx "Hello world")
show (fun ctx id -> id |> sprintf "Hello world, %s" |> Controller.text ctx)
}
let func log = azureFunction {
host_prefix "/api"
use_router testCntl
logger log
}
[<FunctionName("HelloWorld")>]
let helloWorld ([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, Route = "{route?}")>]req: HttpRequest, log: ILogger) =
// This warning actually gets logged
log.LogWarning("logging does work")
func log req
You can see, that the warning inside the helloWorld function gets printed, while the logger of the index route doesn't.
Setting the logger via the
azureFunction
computation expression and then getting it withctx.GetLogger()
doesn't actually log anything.How to reproduce: Take the
Saturn.Func
sample from this repo and update the source code ofSaturnFunc.fs
and run the function app:You can see, that the warning inside the
helloWorld
function gets printed, while the logger of the index route doesn't.