Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json log formatter #992

Closed
daxartio opened this issue Aug 25, 2022 · 2 comments · Fixed by #1027
Closed

Json log formatter #992

daxartio opened this issue Aug 25, 2022 · 2 comments · Fixed by #1027
Assignees

Comments

@daxartio
Copy link

Problem

I want to configure log formatter of server, for example, use json formate in log output.

Ideal Solution

From env to receive log format and to configure logrus.

import (
  log "github.com/sirupsen/logrus"
)

func init() {
  if EnvLogFormat == "json" {
    log.SetFormatter(&log.JSONFormatter{})
  } else {
    log.SetFormatter(&log.TextFormatter{})
  }
}
@markphelps
Copy link
Collaborator

thanks @daxartio , I agree this would be a great feature. I'm actually looking into replacing logrus with zap or similar #964, so I wonder if it would make sense to implement this as part of that work?

@daxartio
Copy link
Author

Yeah, good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants