title: How do you create a basic database logger for uber-go.zap?
body: <p>I have been searching for examples of how to implement a database logger for <code>uber-go.zip</code> that will insert the <code>message</code> and <code>fields</code> into a database table for querying. (So no encoding) No luck so far finding some examples, so I am starting with the example from here:</p>
  <p><a href="https://stackoverflow.com/questions/70512120/how-to-access-fields-in-zap-hooks">How to access Fields in zap Hooks?</a></p>
  <p>But the code doesnt even appear to do what it suggests it should do, here is my example:</p>
  <p><a href="https://go.dev/play/p/9AugEsYwA-E" rel="nofollow noreferrer">https://go.dev/play/p/9AugEsYwA-E</a></p>
  <pre><code>package main
  
  import (
      &quot;errors&quot;
      &quot;fmt&quot;
  
      &quot;go.uber.org/zap&quot;
      &quot;go.uber.org/zap/zapcore&quot;
  )
  
  func main() {
      fmt.Println(&quot;Hello, 世界&quot;)
      l, _ := zap.NewProduction()
      logger := zap.New(&amp;CqlLogCore{Core: l.Core()})
  
      logger.Info(&quot;some logging info&quot;,
          zap.Int(&quot;count&quot;, 17),
          zap.Error(errors.New(&quot;boom&quot;)))
  
  }
  
  type CqlLogCore struct {
      zapcore.Core
  }
  
  func (c *CqlLogCore) Write(entry zapcore.Entry, fields []zapcore.Field) error {
      fmt.Println(&quot;hi&quot;, entry, fields)
      return c.Core.Write(entry, fields)
  }
  </code></pre>
  <p>The test log message with &quot;hi&quot; is not dumped to stdout. Can someone please point me to where I am going wrong, or an example database logger.</p>
  <p>Thanks!</p>