Created: 2014-05-18 20:58
Updated: 2019-01-29 00:05
License: mit


Simple F# helper for NLog


  • NuGet
    • Using the Package Manager Console:

       PM> Install-Package NLog.FSharp
    • Using paket:

       >./.paket/paket.exe add NLog.FSharp --project MyProject


>open NLog.FSharp

>let log = new Logger()        // logger name is determined using the caller type
>let log = new Logger("mylog") // or use an explicit logger name
>let log = new Logger(logger)  // or any NLog.Logger

>let text = "Welcome"
>log.Info "Text:%s" text       // <- use formatted text

// use formatted input with any of these:
>log.{Trace, Debug, Info, Warn, Error, Fatal} "More than one number %M or %i" 3.0m 7

// or with exceptions
>let e, i = new System.Exception(), 3
>log.InfoException e "An exception has occurred %d times" i

More examples of formatted text in F# are available here.


For information on NLog configuration files, visit the NLog wiki. Use this resource to determine what to log and where to log it when you need to capture output at runtime.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more