Application File Logger

  1. func main() {
  2. app := iris.Default()
  3. // Logging to a file.
  4. // Colors are automatically disabled when writing to a file.
  5. f, _ := os.Create("iris.log")
  6. app.Logger().SetOutput(f)
  7. // Use the following code if you need to write the logs
  8. // to file and console at the same time.
  9. // app.Logger().AddOutput(os.Stdout)
  10. app.Get("/ping", func(ctx iris.Context) {
  11. ctx.WriteString("pong")
  12. })
  13. app.Listen(":8080")
  14. }