Using yesod 1.6.2.1, when creating a new application (regardless of whether using the scaffolding or using the builtin warp port foundation), you get request logs like this:
127.0.0.1 - - [18/Aug/2023:11:19:54 +0200] "GET / HTTP/1.1" 200 ...
I don't see where/how they're configured. The Yesod typeclass comes with a shouldLogIO member, but even if that's set to return False you still get these messages on each request. While these are mostly harmless, I'd at least like to disable them in tests because the mess up the test runner output.
What actually creates these log entries, and how do I configure/disable them?
These logs come from a WAI middleware that the
warphelper inyesodas well as the scaffolding create. There doesn't seem to be a central place to configure this by default, however it can be disabled by simply not including the middleware in question.In the scaffolded site, this is in the
withAppfunction inTestImport.hs:simply replace
(foundation, logWare)with(foundation, id)here (this works since WAI middlewares are simply functions of typeApplication -> Application).Similarly, in the scaffolded site, you can just remove
logWarefrommakeApplicationinApplication.hs:When not using the scaffolded site, to run the application without the default logging middleware just do something similar to the scaffolded site and convert your foundation to a WAI app via
toWaiAppPlain, add the default middlwares without logging viadefaultMiddlewaresNoLogging, and useNetwork.Wai.Handler.Warp.runto run the resulting WAI application with the warp server`.