Flexible, configurable, monadic and pretty logging


Version on this page:1.8.11
LTS Haskell 11.22:1.8.11
Stackage Nightly 2018-03-12:
Latest on Hackage:1.9.0

See all snapshots log-warper appears in


Build Status Hackage Stackage LTS Stackage Nightly License: MIT

log-warper is a high level and featureful logging library with monadic interface.

You can jump right into introduction tutorial to see how to write logging with log-warper.


Here is the list of features log-warper provides.

  1. Hierarchical logger names.

    Logger names (tags for loggers) form hierarchy. It means, that "" (also known as mempty or rootLoggerName) is a parent of logger with name "node" which is a parent of logger with name "node.communication". So, logger name comprises dot-separated components. This means that if some logger name doesn’t have some settings (like severity or output file) it takes its settings from the closest parent, containing this settings.

  2. Logging initialization from .yaml configuration file.

    Whole logging configuration can be specifed in a single .yaml file. See example here.

  3. Monadic logging interface.

    log-warper uses mtl-style type classes to provide monadic interfaces for logging.

  4. Strict StateT based pure logging.

    See this tutorial on pure logging with log-warper.

  5. Different severity levels of messages with the ability to configure Set of severities.

  6. Output is colored :star:

    When you log messages, you see time of this logging message, logger name, severity and ThreadId. Message formatting is configurable. Color or logged message tag depends on Severity for this message.

  7. Flexible and easy creation of LoggerConfig using monoidal builders and lenses.

    In case .yaml configuration is not enough for you, you can use lens-based EDSL to create configurations. LoggerConfig also implements instances for Semigroup and Monoid so you can combine your configurations from different sources (CLI and .yaml for example).

  8. Logger rotation.

    log-warper supports logger rotation. Yes, there exist logrotate and similar tools. But it’s not easy to configure cross-platform (Windows, Linux, OSX) logging rotation with external tools.

  9. Ability to acquire last N megabytes of logs from in-memory cache.

    In case you want to analyze logging messages you can take them from in-memory cache.

Reference guide (FAQ)

Here you can find hints and tips how to achieve desired behavior with log-warper.

  1. How can I redirect all output to stderr?

    • Write termSeveritiesErr: All on top-level of your .yaml file.
  2. How can I disable only Error messages for my logger?

  3. How can I show ThreadId inside log message?

    • Add showTid: true to your .yaml file.
  4. How to easily disable terminal output?

    • Put these lines into .yaml file:
    termSeveritiesOut : []
    termSeveritiesErr : []
  5. How can I enable messages with severity Info and higher?

    • Write severity: Info+ inside tree node of your logger settings.
  6. How can I log inside functions like forkIO?

    • Use liftLogIO function. Its Haddock contains nice usage example.
  7. How can I easily log exceptions without throwing them?


This project uses universum as default prelude



  • Resolve LW-34 bug, which was causing improper message handling in nonexisting loggers

  • Make o-clock non-optional dependency.


  • Remove exception handler from simple logger, which would catch all exceptions, even asynchronous ones.


  • Bump up lower bounds for universum and o-clock packages.


  • Increase upper bound for ansi-terminal to < 0.9.


  • #52: Add System.Wlog.Concurrent module for ghc-8.2.2 which allows to run action in parallel with logging.


  • Bump up universum to v1.0.4.


  • #89: Add upper-bounds for dependencies. Also use build-tool-depends field for markdown-unlit.


  • #86: Add lens for changing properties of the particular logger.
  • Ungrade universum to the 1.0.2.


  • #79: Add launchWithConfig to Launcher module.


  • Migrate to universum-1.0.0.
  • #71: Use microlens-platform instead of lens. LoggerMap is now has field LoggerName instead of Text. zoomLogger is now work with LoggerName instead of Text. Remove LogHandler.Syslog module and network library. Remove extra, errors, exceptions, hashable, text-format, formatting dependencies. Remove loggerNameF function. Change lens to microlens-mtl in tests.


  • #75: Bump up universum lower bound.


  • #55: Return back lcFilePrefix field in LoggerConfig, rename to lcLogsDirectory.


  • Upgrade universum to version 0.9.1. Add Semigroup instances.


  • Relax containers package dependency from >= to >= Also use stable LTS for building package.


  • #55: Remove lcFilePrefix field from LoggerConfig.


  • #61: Add launchFromFile, defaultConfig and launchSimpleLogging functions.


  • #57: Add Exception module with logException and catchLog functions.
  • #60: Fix documentation for termSeveritiesOut and termSeveritiesErr.
  • #63: Timestamp rounding by powers of 10.


  • Bump containers to version 0.5.10.


  • #48: Output for severities is now configured in config file with termSeveritiesOut and termSeveritiesErr for writing into stdout and stderr accordingly. Default behavior: Errors into stderr, all other into stdout.
  • In yaml config file added new keywords for dealing with Severities: ‘All’ – all severities, ‘X+’ – severities greater or equal to X.
  • Changed .yaml format: logger severity receives set of severities (Severities).
  • #32: Changed .yaml format: LoggerTree should be written under ‘loggerTree:’.
  • #49: Add WithLoggerIO constraint.
  • #50: Add liftLogIO function into CanLog module.


  • Error is now printed only to stderr, all other messages to stdout.
  • Logger severity is now Set Severity.
  • Interface changes: functions which worked with Severity now work with Set Severity.
  • Remove releaseAllHandlers, streamHandlerWithLock, trapLogging, debugM, errorM, infoM, noticeM, warningM.
  • Rename Wrapper module to Terminal.
  • Rename Handler module to LogHandler.
  • Rename Logger module to IOLogger.
  • Move setSeverity and setSeverityMaybe to IOLogger.
  • Lift all functions inside IOLogger module to MonadIO.
  • handle from LogHandler module is renamed to logHandlerMessage and moved out of type class LogHandler.


  • Add launchNamedPureLogWith to PureLogging
  • Improve documentation for launchNamedPureLog


  • Add logPureAction to PureLogging.
  • Add withSublogger to HasLoggerName.


  • Add usingNamedPureLogger to PureLogging.


  • Replace String to Text in LoggerName.
  • Rename LoggerName field name to getLoggerName.
  • Rename getLoggerName of HasLoggerName class to askLoggerName.
  • Use LoggerName instead of Text where possible.
  • Make separate HasLoggerName module.
  • Make separate PureLogging module.
  • Remove safecopy dependency and refactor code.


  • Add logEvents function to log [LogEvent] with proper logName.


  • Add ability to specify custom logging action.


  • Correct logger config parsing


  • Fixed a bug related to ugly output to stdout even when it was turned off.


  • Minor dependencies update.


  • Fix minor bug with stdout severity.


  • Allow to use arbitrary text formatter function.


  • Add ability to specify time format for logs.
  • Some space leaks elimination:
    • The MemoryQueue has been partially reworked to get rid of the “inline” State manipulation;
    • Strings have been dropped almost everywhere in favour of Text;
    • A LogFormatter has been reworked to yield a IO Builder;
    • replaceVarM has been reworked to be pure and to work with builders rather than plain Text/Strings;
    • The pure logger has been reworked to use strict’s StateT instead of WriterT;
    • The pure logger have been polished to drop instances which required the UndecidableInstances pragma;
    • The Sized instance for Text has been reworked and multiplied by a constant factor of 16 (see below).


  • Now we create a directory for log files if it’s missing.


  • Fixed memory leak (PR #17).


  • Supports Unix paths in log configs even on Windows.


  • Uses universum-0.6.1.


  • Add CanLog and HasLoggerName instances for both strict and lazy State.


  • Add config parameter to print ThreadId optionally.
  • Boolean monoidal builders for LoggerConfig now set boolean parameter to default ≠ mempty parameter.