Logging to from Logary

Logary is a semantic logging framework like Serilog and Microsoft Semantic Logging. Combining semantic logs with is a perfect fit since has been designed with semantics from the ground up.

In this tutorial, we’ll add Logary to a Console application, but the process is almost identical to other project types. Create a new console application and add the target for Logary:

Install-Package Logary.Targets.ElmahIO
dotnet add package Logary.Targets.ElmahIO
<PackageReference Include="Logary.Targets.ElmahIO" Version="5.*" />
paket add Logary.Targets.ElmahIO

Configuration in F#

Configure just like you would any normal target:

withTargets [
  // ...
  ElmahIO.create { logId = Guid.Parse "LOG_ID"; apiKey = "API_KEY" } ""
] >>
withRules [
 // ...
 Rule.createForTarget ""

where LOG_ID is the id of your log (Where is my log ID?).

Configuration in C#

Configuration in C# is just as easy:

  conf => conf.Target.SendTo(logId: "LOG_ID", apiKey: "API_KEY"))

where API_KEY is your API key and LOG_ID is the ID of your log.


To start logging messages to, you can use the following F# code:

let logger = logary.getLogger (PointName [| "Logary"; "Samples"; "main" |])

Message.event Info "User logged in"
  |> Message.setField "userName" "haf"
  |> Logger.logSimple logger

or in C#:

var logger = logary.GetLogger("Logary.CSharpExample");
logger.LogEventFormat(LogLevel.Fatal, "Unhandled {exception}!", e);

This article was brought to you by the team. is the best error management system for .NET web applications. We monitor your website, alert you when errors start happening, and help you fix errors fast.

See how we can help you monitor your website for crashes Monitor your website