Logging to file

(Mantielero) #1

How can I set badger up to log to an output file?

I have something like the following to avoid polluting the output:

opt := badger.DefaultOptions
opt.Logger = nil

Disclaimer: I am a newbie in both go and badger (not a professional developper myself).

Jose Maria

(Martin Martinez Rivera) #2

Check the logger interface in logger.go. You can write an implementation of that interface that writes to a file in order to do what you want.

I guess it’s not exactly newbie-friendly since it requires you to write code but it shouldn’t be too hard if you use something like https://godoc.org/github.com/golang/glog to do the bulk of the work.