Can I log redirect?

This is caddyfile: {
  root /var/www/
timeouts none
realip cloudflare
log / /etc/caddy/access.log "{remote} - {user} [{when}] \"{method} {uri} {proto}\" {status} {size} \"{>Referer}\" \"{>User-Agent}\""
import redir_rule
  redir /source

Log is empty if website is redirected to
Log has all the info if not redirected.
@magikstm, you are right. The forum remove some symbols when I paste content of caddyfile. I edited my post just now. This log does not record anything before redirection.

Replace the “/” after your log for "".

I was unable to execute your log line as-is.

Try something like:

log "" access.log "{remote} | {user} | {when} | {method} | {uri} | {proto} | {status} | {size} | {latency_ms}"

New reply after main post edit.

Try changing your log line to this:

log "" /etc/caddy/access.log "{remote} - {user} [{when}] \"{method} {uri} {proto}\" {status} {size} \"{>Referer}\" \"{>User-Agent}\""

hi magikstm
Your code worked. After I got your code I cleared my browser cache to test again and worked. Now I am sure caddy log will do record before redirect. Thank you very much you have solved my confusion.

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