How to log to a db?

How could I redirect logging to a db, .e.g. MySQL?

I see a few ways, but none provide the ready solution, in my understanding:

  1. Use Base.logging(io,…) to redirect info/warn/error to an IOStream, which would need to be listening and writing to a db; problem: how to implement this IOStream listening, async?

  2. Use a logging package; problem: none of them seem to have implemented writing to a db - why? Is it for some reason not advisable to log to a db?

  3. Use ZMQ somehow…is it possible to get an IOStream which is the input into a ZMQ PUB socket, where the SUB end writes to a db; problem: if I cannot get an IOStream directly, I am back to the problem in 1)

  4. Just implement own log.info etc. methods to write to a db; no problem, but seems like this should be available in logging packages

Thanks

1 Like