Logging Request to debug 404 error

I’m getting a 404 on one of my endpoints and trying to debug what is happening when a requests comes in. I have printed statements in my code to print to the console like fmt.Println(). I added these to my Caddyfile
log stdout
errors syslog

just trying to figure out best we to see my logs and have good logging with Caddy.

Hi @q45, saw your thread over in the usegolang.com slack! Welcome to the Caddy community.

log stdout will effectively send all access logs to wherever Caddy was launched from. From that slack thread, you’re using systemd to run Caddy, and you’ve already found journalctl -r.

You could also use log /var/www/caddy-access.log or similar. Then you can tail that file to find out what’s going on.

According to the docs, large log files get rolled by default, but you can tweak the log rotation settings if you like.


1 Like

Matthew is right. Those two directives will log HTTP requests and errors. You can also enable Caddy’s process log with the -log CLI flag.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.