# How to log to a db?

**URL:** <https://discourse.julialang.org/t/how-to-log-to-a-db/4463>\
**Category:** General Usage\
**Created:** [June 26, 2017, 6:41am UTC](https://discourse.julialang.org/t/how-to-log-to-a-db/4463 "2017-06-26T06:41:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kimran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kimran/32/7782_2.png) [@kimran](https://discourse.julialang.org/u/kimran)\
**Post date:** [June 26, 2017, 6:41am UTC](https://discourse.julialang.org/t/how-to-log-to-a-db/4463/1 "2017-06-26T06:41:39Z")

</div>

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
