Skip to content

Error value in log.Fields disappears when using JSON formatter #137

@rsterbin

Description

@rsterbin

When passing an error as a field and using the JSON formatter, the error message is omitted:

package main

import "errors"
import log "github.com/Sirupsen/logrus"

func main() {
    err := errors.New("Here is an error message")
    log.WithFields(log.Fields{
        "error": err,
    }).Error("Logging without json")
    log.SetFormatter(&log.JSONFormatter{})
    log.WithFields(log.Fields{
        "error": err,
    }).Error("Logging with json")
}

Results:

ERRO[0000] Logging without json                          error=Here is an error message
{"error":{},"level":"error","msg":"Logging with json","time":"2015-02-26T20:32:02Z"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions