Can I log redirect?

(nudylady) #1

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.

(Magikstm) #2

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}"

(Magikstm) #3

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}\""

(nudylady) #4

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.