title: How to initialize a zap logger once and reuse it in other Go files?
body: <p>I'm trying to migrate my application from the beautiful Logrus (very helpful for debug) and introducing the Uber log framework Zap.</p>
  <p>With Logrus, I can initialize the logger only once and reuse it from other Go file, an example:</p>
  <pre class="lang-golang prettyprint-override"><code>package main
  import(
      // Print filename on log
      filename &quot;github.com/onrik/logrus/filename&quot;
      // Very nice log library
      log &quot;github.com/sirupsen/logrus&quot;
  )
  
  func main(){
  
  // ==== SET LOGGING
      Formatter := new(log.TextFormatter)
      Formatter.TimestampFormat = &quot;Jan _2 15:04:05.000000000&quot;
      Formatter.FullTimestamp = true
      Formatter.ForceColors = true
      log.AddHook(filename.NewHook()) // Print filename + line at every log
      log.SetFormatter(Formatter)
  
  }
  </code></pre>
  <p>From other Go file, I'm able to reuse that logger without any other initialization:</p>
  <pre class="lang-golang prettyprint-override"><code>// VerifyCommandLineInput is delegated to manage the inputer parameter provide with the input flag from command line
  func VerifyCommandLineInput() datastructures.Configuration {
      log.Debug(&quot;VerifyCommandLineInput | Init a new configuration from the conf file&quot;)
      c := flag.String(&quot;config&quot;, &quot;./conf/test.json&quot;, &quot;Specify the configuration file.&quot;)
      flag.Parse()
      if strings.Compare(*c, &quot;&quot;) == 0 {
          log.Fatal(&quot;VerifyCommandLineInput | Call the tool using --config conf/config.json&quot;)
      }
      file, err := os.Open(*c)
      if err != nil {
          log.Fatal(&quot;VerifyCommandLineInput | can't open config file: &quot;, err)
      }
      defer file.Close()
      decoder := json.NewDecoder(file)
      cfg := datastructures.Configuration{}
      err = decoder.Decode(&amp;cfg)
      if err != nil {
          log.Fatal(&quot;VerifyCommandLineInput | can't decode config JSON: &quot;, err)
      }
      log.Debug(&quot;VerifyCommandLineInput | Conf loaded -&gt; &quot;, cfg)
  
      return cfg
  }
  
  </code></pre>
  <p>My question is: using the Zap log framework, how can I initialize the log in the main function and use that logger from the other Go file?</p>