Fable.Logging
0.12.3
See the version list below for details.
dotnet add package Fable.Logging --version 0.12.3
NuGet\Install-Package Fable.Logging -Version 0.12.3
<PackageReference Include="Fable.Logging" Version="0.12.3" />
<PackageVersion Include="Fable.Logging" Version="0.12.3" />
<PackageReference Include="Fable.Logging" />
paket add Fable.Logging --version 0.12.3
#r "nuget: Fable.Logging, 0.12.3"
#:package Fable.Logging@0.12.3
#addin nuget:?package=Fable.Logging&version=0.12.3
#tool nuget:?package=Fable.Logging&version=0.12.3
Fable.Logging
A cross-platform logging framework for Fable. It mirrors the
.NET Microsoft.Extensions.Logging
pattern with ILogger, ILoggerFactory, and ILoggerProvider interfaces, letting you
write idiomatic logging code in F# that works across JavaScript, Python, and Erlang/BEAM.
Packages
| Package | NuGet | Description |
|---|---|---|
Fable.Logging |
Core interfaces, LoggerFactory, ConsoleLogger, JS console logger | |
Fable.Logging.Structlog |
Python structlog provider | |
Fable.Logging.Beam |
Erlang/OTP logger provider |
Quick Start
Create a logger factory, configure it with providers, and start logging:
open Fable.Logging
let factory =
LoggerFactory.Create(fun builder ->
builder.AddProvider(ConsoleLoggerProvider())
builder.SetMinimumLevel(LogLevel.Debug))
let logger = factory.CreateLogger("MyApp.Service")
logger.LogInformation("Application started")
logger.LogDebug("Processing request for {UserId}", box 42)
logger.LogError("Something went wrong")
Platform-Specific Providers
JavaScript (console)
The built-in JS logger maps log levels to the appropriate console.* methods
(console.debug, console.info, console.warn, console.error).
open Fable.Logging
open Fable.Logging.JS
let factory =
LoggerFactory.Create(fun builder ->
builder.AddProvider(LoggerProvider()))
let logger = factory.CreateLogger("MyApp")
logger.LogInformation("Hello from {Platform}!", box "JavaScript")
Python (structlog)
Uses structlog for structured logging with support for both console and JSON output.
open Fable.Logging
open Fable.Logging.Structlog
// Console output (human-readable)
let factory =
LoggerFactory.Create(fun builder ->
builder.AddProvider(ConsoleLoggerProvider()))
// JSON output (machine-readable)
let jsonFactory =
LoggerFactory.Create(fun builder ->
builder.AddProvider(JsonLoggerProvider()))
let logger = factory.CreateLogger("MyApp")
logger.LogInformation("User {Name} logged in", box "Alice")
Erlang/BEAM (OTP logger)
Bridges to the OTP logger module for applications targeting the BEAM runtime.
open Fable.Logging
open Fable.Logging.Beam
let factory =
LoggerFactory.Create(fun builder ->
builder.AddProvider(LoggerProvider()))
let logger = factory.CreateLogger("MyApp")
logger.LogWarning("Connection pool running low: {Available} remaining", box 3)
Log Levels
Log levels match the .NET LogLevel enum:
| Level | Value | Method | Description |
|---|---|---|---|
| Trace | 0 | LogTrace |
Most detailed messages, may contain sensitive data |
| Debug | 1 | LogDebug |
Debugging and development |
| Information | 2 | LogInformation |
General flow of the application |
| Warning | 3 | LogWarning |
Abnormal or unexpected events |
| Error | 4 | LogError |
Errors and exceptions |
| Critical | 5 | LogCritical |
Failures requiring immediate attention |
| None | 6 | Suppresses all logging |
Filtering
Set a minimum log level to filter out less severe messages:
let factory =
LoggerFactory.Create(fun builder ->
builder.AddProvider(ConsoleLoggerProvider())
builder.SetMinimumLevel(LogLevel.Warning))
let logger = factory.CreateLogger("MyApp")
logger.LogDebug("This is filtered out")
logger.LogWarning("This is logged")
Message Templates
Use named placeholders in log messages for structured logging. The placeholder names become keys in the structured log output, while values are substituted positionally:
logger.LogInformation("Order {OrderId} placed by {Customer}", box 1234, box "Alice")
// Output: MyApp - Order 1234 placed by Alice
Logging Exceptions
try
failwith "Something broke"
with ex ->
logger.LogError("Operation failed", ex)
Multiple Providers
The factory dispatches log messages to all registered providers:
let factory =
LoggerFactory.Create(fun builder ->
builder.AddProvider(consoleProvider)
builder.AddProvider(jsonProvider))
// Messages are sent to both providers
let logger = factory.CreateLogger("MyApp")
logger.LogInformation("This goes to all providers")
Writing a Custom Provider
Implement ILoggerProvider and ILogger to create your own logging backend:
open Fable.Logging
type MyLogger(name: string) =
interface ILogger with
member _.Log(state: LogState) =
printfn "[%A] %s: %s" state.Level name state.Format
member _.IsEnabled(logLevel: LogLevel) = true
member _.BeginScope(_) = failwith "Not implemented"
type MyLoggerProvider() =
interface ILoggerProvider with
member _.CreateLogger(name) = MyLogger(name)
member _.Dispose() = ()
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Fable.Core (>= 5.0.0-rc.1)
- FSharp.Core (>= 5.0.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Fable.Logging:
| Package | Downloads |
|---|---|
|
Fable.Giraffe
Giraffe for Fable Python |
|
|
Fable.Logging.Beam
Fable.Logging provider for Erlang/OTP logger on BEAM |
|
|
Fable.Logging.Structlog
Fable.Logging provider for Python structlog |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.12.4 | 50 | 3/29/2026 |
| 0.12.3 | 42 | 3/29/2026 |
| 0.12.2 | 42 | 3/29/2026 |
| 0.12.1 | 54 | 3/28/2026 |
| 0.11.2 | 47 | 3/28/2026 |
| 0.11.1 | 72 | 3/28/2026 |
| 0.11.0 | 67 | 3/28/2026 |
| 0.10.0 | 708 | 10/6/2022 |
| 0.9.0 | 1,330 | 9/23/2022 |
| 0.8.0 | 617 | 9/23/2022 |
| 0.7.0 | 604 | 9/23/2022 |
| 0.6.0 | 591 | 9/19/2022 |
| 0.5.0 | 642 | 9/18/2022 |
| 0.4.0 | 635 | 9/18/2022 |
| 0.3.0 | 730 | 9/17/2022 |
| 0.2.0 | 592 | 9/17/2022 |
| 0.1.0 | 646 | 9/17/2022 |