Thanks for putting this self-contained and working snippet, it helped me a lot!
I had trouble finding how to have access logs with Caddy2 (coming from Caddy 1).
I found this other post Logging doesn't work in 2.0 beta 13? - #2 by francislavoie which hints at using the API like matt suggested here, but after trying multiple times I didn’t found the right way to do it.
Providing a working snippet is great!