I've used Elmah before in a C# project years ago and I have recently started using F# and having a bit of trouble. I have a .Net 6 Web Api project
from This Post I see the key code is:
services.AddElmah<SqlErrorLog>(options =>
{
options.ConnectionString = "Server=localhost;Database=ELMAH;Integrated Security=True;";
});
I am a bit lost as to how to actually get this working in my F# program.fs
It currently looks like this:
[<EntryPoint>]
let main args =
let builder = WebApplication.CreateBuilder(args)
builder.Services.AddControllers()
let app = builder.Build()
app.UseHttpsRedirection()
app.UseAuthorization()
app.MapControllers()
app.Run()
exitCode
The equivalent in F#, and with asp.net minimal API that you are using, would be to put this before let app = ...
:
builder.Services.AddElmah<SqlErrorLog>(fun options ->
options.ConnectionString <- "Server=localhost;Database=ELMAH;Integrated Security=True;"
)