Gomol is a library for structured, multiple-output logging for Go with extensible logging outputs

go, gomol, logging, structured-logging
go get



GoDoc Build Status Code Coverage

Gomol (Go Multi-Output Logger) is an MIT-licensed Go logging library. The documentation at this point is thin but will be improving over time.


  • Attach meta-data to each log message with attributes
  • Multiple outputs at the same time


The recommended way to install is via

go get
import ""

Gomol can also be installed the standard way as well

go get
import ""


Right now there are a number of loggers built directly into the gomol library. This adds a number of dependencies that I'd like to remove so I'm in the process of splitting each logger out to its own package. The supported log outputs are listed below. If you have a logger you've written to support gomol and you'd like to add it to this list please either submit a pull request with the updated document or let me know and I can add it!

  • Console - built into gomol at the moment
  • Graylog Extended Log Format (GELF) - built into gomol at the moment
  • Loggly -
  • io.Writer - built into gomol at the moment


For brevity a lot of error checking has been omitted, be sure you do your checks!

This is a super basic example of adding a number of loggers and then logging a few messages:

package main

import (

func main() {
    // Add a console logger
    consoleCfg := gomol.NewConsoleLoggerConfig()
    consoleLogger, _ := gomol.NewConsoleLogger(consoleCfg)

    // Add a GELF logger
    gelfCfg := gomol.NewGelfLoggerConfig()
    gelfCfg.Hostname = "localhost"
    gelfCfg.Port = 12201

    // Set some global attrs that will be added to all
    // messages automatically
    gomol.SetAttr("facility", "gomol.example")
    gomol.SetAttr("another_attr", 1234)

    // Initialize the loggers
    defer gomol.ShutdownLoggers()

    // Log some debug messages with message-level attrs
    // that will be sent only with that message
    for idx := 1; idx <= 10; idx++ {
            "msg_attr1": 4321,
        }, "Test message %v", idx)