title: Gin outputs to a file
body: <p>I'm using Gin to make REST API server and Gin shows its output on a console like this: <a href="https://i.stack.imgur.com/r0LF5.png" rel="nofollow noreferrer">Gin console example</a></p>
  <p>I'd like to make gin's output to a file instead of console.</p>
  <p>What I've found is below code from Gin/mode.go</p>
  <pre><code>// DefaultWriter is the default io.Writer used the Gin for debug output and
  // middleware output like Logger() or Recovery().
  // Note that both Logger and Recovery provides custom ways to configure their
  // output io.Writer.
  // To support coloring in Windows use:
  //      import &quot;github.com/mattn/go-colorable&quot;
  //      gin.DefaultWriter = colorable.NewColorableStdout()
  var DefaultWriter io.Writer = os.Stdout
  var DefaultErrorWriter io.Writer = os.Stderr
  </code></pre>
  <p>Looks like I can change DefaultWriter and DefaultErrorWriter's behavior by setting like</p>
  <pre><code>gin.DefaultWriter = something
  </code></pre>
  <p>on my code.</p>
  <p>But I have no idea how to write that 'something' code; it must be a function which writes to a file but have no idea how/where to start.</p>
  <p>So, my questions are:</p>
  <ol>
  <li>Am I heading to the right direction?</li>
  <li>How to write that 'something' function? It would be very helpful if you can provide an example.</li>
  </ol>
  <p>Thank you.</p>