package main import ( "github.com/kataras/iris/v12" "github.com/kataras/iris/v12/middleware/accesslog" "xps/bootstrap" "xps/web/middleware/identity" "xps/web/router" ) const maxSize = 20 * 1024 * 1024 func newApp() *bootstrap.Bootstrapper { app := bootstrap.New("web", "yafeng") app.Bootstrap() //ac := makeAccessLog() //defer ac.Close() //app.UseRouter(ac.Handler) app.Configure(identity.Configure, router.Configure) return app } // Read the example and its comments carefully. func makeAccessLog() *accesslog.AccessLog { // Initialize a new access log middleware. ac := accesslog.File("./access.log") // Remove this line to disable logging to console: //ac.AddOutput(os.Stdout) // The default configuration: ac.Delim = '|' ac.TimeFormat = "2006-01-02 15:04:05" ac.Async = false ac.IP = true ac.BytesReceivedBody = true ac.BytesSentBody = true ac.BytesReceived = false ac.BytesSent = false ac.BodyMinify = true ac.RequestBody = true ac.ResponseBody = false ac.KeepMultiLineError = true ac.PanicLog = accesslog.LogHandler // Default line format if formatter is missing: // Time|Latency|Code|Method|Path|IP|Path Params Query Fields|Bytes Received|Bytes Sent|Request|Response| // // Set Custom Formatter: ac.SetFormatter(&accesslog.JSON{ Indent: " ", HumanTime: true, }) return ac } func main() { app := newApp() app.Listen(":8001", iris.WithPostMaxMemory(maxSize)) }