BSD-3-Clause licensed by Ozgun Ataman, Michael Xavier
Maintained by [email protected]
This version can be pinned in stack with:katip-,4206

Module documentation for

Katip Build Status

Katip is a structured logging framework for Haskell.


Kâtip (pronounced kah-tip) is the Turkish word for scribe.


  • Structured: Logs are structured, meaning they can be individually tagged with key value data (JSON Objects). This helps you add critical details to log messages before you need them so that when you do, they are available. Katip exposes a typeclass for log payloads so that you can use rich, domain-specific Haskell types to add context that will be automatically merged in with existing log context.

  • Easy Integration: Katip was designed to be easily integrated into existing monads. By using typeclasses for logging facilities, individual subsystems and even libraries can easily add their own namespacing and context without having any knowledge of their logging environment.

  • Practical Use: Katip comes with a set of convenience facilities built-in, so it can be used without much headache even in small projects.

    • A Handle backend for logging to files in simple settings.

    • A AnyLogPayload key-value type that makes it easy to log structured columns on the fly without having to define new data types.

    • A Monadic interface where logging namespace can be obtained from the monad context.

    • Multiple variants of the fundamental logging functions for optionally including fields and line-number information.

  • Extensible: Can be easily extended (even at runtime) to output to multiple backends at once (known as scribes). See katip-elasticsearch as an example. Backends for other forms of storage are trivial to write, including both hosted database systems and SaaS logging providers.

  • Debug-Friendly: Critical details for monitoring production systems such as host, PID, thread id, module and line location are automatically captured. User-specified attributes such as environment (e.g. Production, Test, Dev) and system name are also captured.

  • Configurable: Can be adjusted on a per-scribe basis both with verbosity and severity.

    • Verbosity dictates how much of the log structure should actually get logged. In code you can capture highly detailed metadata and decide how much of that gets emitted to each backend.

    • Severity AKA “log level” is specified with each message and individual scribes can decide whether or not to record that severity. It is even possible to at runtime swap out and replace loggers, allowing for swapping in verbose debug logging at runtime if you want.

  • Battle-Tested: Katip has been integrated into several production systems since 2015 and has logged hundreds of millions of messages to files and ElasticSearch.


Be sure to look in the examples directory for some examples of how to integrate Katip into your own stack.



  • Add support for rendering arrays in the log context to the handle scribe #150

  • Allow up to GHC 9.6 for Windows #145

  • unix 2.8 compatibility #143

  • MTL 2.3 compatibility #140

  • Text 2 compatibility #138

  • Aeson 2 compatibility #131

  • GHC 8.10 compatibility

  • Add MonadResource instances #121

  • Add support for unliftio-core 0.2 while maintaining backwards-compatible support for 0.1

  • Add logKatipItem function and reimplement logItem to use it. vlatkoB

  • Add MonadFail instances for base >= Koray Al

  • Breaking change: switch from severity based log level filtering to user-definable PermitFunc. To upgrade, any time you initialize one of the standard scribes, rather than providing a severity like InfoS, instead pass in (permitItem InfoS). Credit to vlatkoB.
  • Update some misformatted and outdated docs.
  • Set lower bound of base to, the version shipped with GHC 8.0.2. Support for GHC versions older than that is removed.
  • Update default formatter of Handle scribe to format pid as [PID 1234] instead of [1234] and [ThreadId 1234] instead of [1234].
  • Add missing Bounded instance for Verbosity. This allows you to easily enumerate all verbosities via [minBound..maxBound].

  • Exclusively use HasCallstack for location reporting in errors. Credit to Domen Kožar
  • Drop support for GHC 7.x

  • Add mkHandleScribeWithFormatter. This allows control over the format of log items going to a handle. Credit to Tristan Bull for the implementation.
  • Documentation fixes. Credit to Domen Kožar for the implementation.
  • Add jsonFormat handle formatter.
  • Deprecate formatItem which is now replaced by bracketFormat.

  • Loosen deps
  • Support latest STM

  • Drop ListT instance due to deprecations.
  • Loosen dependencies.

  • Decrease default timer resolution from 1s to 1ms.

  • Export runNoLoggingT and NoLoggingT constructor.
  • Delegate MonadReader instance for NoLoggingT.

  • Loosen bounds on resourcet and template-haskell.
  • Add convenience function askLoggerIO.

  • Add MonadUnliftIO instances.
  • Add NoLoggingT

  • Allow newer versions of either by conditionally adding instances for the removed EitherT interface.

  • Add mkFileScribe, a specialization of mkHandleScribe for files that manages the handle automatically.

  • Loosen Win32 upper bound to run with GHC 8.2 on Windows.

  • Add worked example of Katip/KatipContext to the haddocks.

  • Export Katip.Compat for Windows users.

  • Fix numeric formatting in Handle scribe.
  • Bump deps for GHC 8.2.1

  • Improved documentation.
  • Add built-in buffering to scribes. Scribes now allocate a bounded queue (with configurable size). Rather than writes being synchronous to all scribes, they simply attempt to write into the bounded queue of each scribe. If any of the scribes is too far behind and the queue is full, the write is dropped. This also means that closing scribes is now an IO operation that happens synchrounsly.
  • Added local-like functions to Katip and KatipContext typeclasses. This allows us to generalize katipNoLogging, katipAddNamespace, and katipAddContext to be available to anything with a Katip or KatipContext instance rather than having to reimplement these functions all the time.

  • Add Katip instances for Strict StateT, WriterT, RWST.
  • Add Katip instances for Lazy RWST.

  • Drop unsafe _ioLogEnv for safe ioLogEnv

  • Add Semigroup instance for LogStr.

  • Loosen deps on aeson to allow

  • Fix build on windows

  • Add some missing test files

  • Fix some example code that wasn’t building
  • Make FromJSON instance for Severity case insensitive.

  • Add support for aeson 1.0.x
  • Add Katip.Format.Time module and use much more efficient time formatting code in the Handle scribe.

  • Switch from regex-tdfa-rc to regex-tdfa.
  • Add katipNoLogging combinator.
  • Add Semigroup instances.
  • Drop ToJSON superclass requirement fro ToObject. Instead, ToObject will provide a default instance for types with an instance for ToJSON. This gets us to the same place as before without having to add a broader instance for something that’s only going to show up in logs as an Object.
  • Add a simple MVar lock for file handle scribes to avoid interleaved log lines from concurrent inputs.

  • Add GHC implicit callstack support, add logLoc.
  • Drop lens in favor of type-compatible, lighter microlens.
  • Renamed logEnvNs to clearer logEnvApp
  • Added katipAddNamespace and katipAddContext
  • Fixed nested objects not rendering in Handle scribe.
  • LogContexts Monoid instance is now right-biased rather than left biased. This better fits the use case. For instance ctx1 <> ctx2 will prefer keys in ctx2 if there are conflicts. This makes the most sense because functions like katipAddContext will mappend on the right side.
  • LogContext internally uses a Seq instead of a list for better complexity on context add.
  • Improved documentation.

  • Set upper bounds for a few dependencies.
  • Add ExceptT instance for Katip typeclass

  • Initial release