V2 debug logging

1. My Caddy version (caddy version):

V2 RC3

2. How I run Caddy:

/caddy2.0rc3 run -config /data/caddy/config2 -adapter caddyfile

a. System environment:

Linux 18.04

b. Command:

c. Service/unit/compose file:

d. My complete Caddyfile or JSON config:

test.site {
     root * /data/www/re/test/
     file_server /*
    log {
       level DEBUG
       output file /data/log/caddy_test.log {
           roll_size 10MiB
           roll_keep 10
           roll_keep_for 336h
       }
    }

    rewrite /*.nomedia /forbidden
    respond /forbidden 403
}

3. The problem I’m having:

Based on the config I should be seeing debug messages in the log I believe. I’ve read the docs and I think what I have is correct but the logs only show info level messages.

4. Error messages and/or full log output:

The debug messages are absent.

If I access that site with test.site/test.nomedia

I’ll get a info and an error but I was expecting DEBUG info like I see on teh console.

Console:

{"level":"debug","ts":1587660775.125461,"logger":"http.handlers.rewrite","msg":"rewrote request","request":{"method":"GET","uri":"/test.nomedia","proto":"HTTP/2.0","remote_addr":":35574","host":"www..com","headers":{"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36"],"Sec-Fetch-Mode":["navigate"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"],"Sec-Fetch-Site":["cross-site"],"Sec-Fetch-User":["?1"],"Sec-Fetch-Dest":["document"],"Accept-Encoding":["gzip, deflate, br"],"Pragma":["no-cache"],"Cache-Control":["no-cache"],"Dnt":["1"],"Accept-Language":["en-US,en;q=0.9"]},"tls":{"resumed":false,"version":772,"ciphersuite":4865,"proto":"h2","proto_mutual":true,"server_name":"www..com"}},"method":"GET","uri":"/forbidden"}
{"level":"error","ts":1587660775.1255589,"logger":"http.log.access.log2","msg":"handled request","request":{"method":"GET","uri":"/test.nomedia","proto":"HTTP/2.0","remote_addr":":35574","host":"www..com","headers":{"Sec-Fetch-Dest":["document"],"Accept-Encoding":["gzip, deflate, br"],"Pragma":["no-cache"],"Cache-Control":["no-cache"],"Dnt":["1"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"],"Sec-Fetch-Site":["cross-site"],"Sec-Fetch-User":["?1"],"Accept-Language":["en-US,en;q=0.9"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36"],"Sec-Fetch-Mode":["navigate"]},"tls":{"resumed":false,"version":772,"ciphersuite":4865,"proto":"h2","proto_mutual":true,"server_name":"www..com"}},"common_log":" - - [23/Apr/2020:12:52:55 -0400] \"GET /test.nomedia HTTP/2.0\" 403 0","latency":0.000116576,"size":0,"status":403,"resp_headers":{"Content-Type":[],"Server":["Caddy"]}}

Log:

{"level":"error","ts":1587660775.1255589,"logger":"http.log.access.log2","msg":"handled request","request":{"method":"GET","uri":"/test.nomedia","proto":"HTTP/2.0","remote_addr":":35574","host":"www..com","headers":{"Dnt":["1"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"],"Sec-Fetch-Site":["cross-site"],"Sec-Fetch-User":["?1"],"Sec-Fetch-Dest":["document"],"Accept-Encoding":["gzip, deflate, br"],"Pragma":["no-cache"],"Cache-Control":["no-cache"],"Accept-Language":["en-US,en;q=0.9"],"Sec-Fetch-Mode":["navigate"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36"]},"tls":{"resumed":false,"version":772,"ciphersuite":4865,"proto":"h2","proto_mutual":true,"server_name":"www..com"}},"common_log":" - - [23/Apr/2020:12:52:55 -0400] \"GET /test.nomedia HTTP/2.0\" 403 0","latency":0.000116576,"size":0,"status":403,"resp_headers":{"Content-Type":[],"Server":["Caddy"]}}

5. What I already tried:

I’ve read many docs but I still do not understand. I’ve tried DEBUG and debug (different case).

6. Links to relevant resources:

above

Thanks for all the help. I saw logging was added lateron. Maybe all the fixes aren’t in RC3?

Hmm, your Caddyfile seems to be missing the site name – actually, how is that even working at all? The first line of the Caddyfile should be the address of the site to serve.

The question was meant as a sanity check that what I was expecting to see was correct. There are a number of sites with that log definition but here is one.

Removed. Let me add a better site with a rewrite. One moment.

If I access that site with test.site/test.nomedia

I’ll get a info and an error but I was expecting DEBUG info like I see on teh console.

test.site {
     root * /data/www/re/test/
     file_server /*
    log {
       level DEBUG
       output file /data/log/caddy_test.log {
           roll_size 10MiB
           roll_keep 10
           roll_keep_for 336h
       }
    }

    rewrite /*.nomedia /forbidden
    respond /forbidden 403
}

Console:

{"level":"debug","ts":1587660775.125461,"logger":"http.handlers.rewrite","msg":"rewrote request","request":{"method":"GET","uri":"/test.nomedia","proto":"HTTP/2.0","remote_addr":":35574","host":"www..com","headers":{"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36"],"Sec-Fetch-Mode":["navigate"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"],"Sec-Fetch-Site":["cross-site"],"Sec-Fetch-User":["?1"],"Sec-Fetch-Dest":["document"],"Accept-Encoding":["gzip, deflate, br"],"Pragma":["no-cache"],"Cache-Control":["no-cache"],"Dnt":["1"],"Accept-Language":["en-US,en;q=0.9"]},"tls":{"resumed":false,"version":772,"ciphersuite":4865,"proto":"h2","proto_mutual":true,"server_name":"www..com"}},"method":"GET","uri":"/forbidden"}
{"level":"error","ts":1587660775.1255589,"logger":"http.log.access.log2","msg":"handled request","request":{"method":"GET","uri":"/test.nomedia","proto":"HTTP/2.0","remote_addr":":35574","host":"www..com","headers":{"Sec-Fetch-Dest":["document"],"Accept-Encoding":["gzip, deflate, br"],"Pragma":["no-cache"],"Cache-Control":["no-cache"],"Dnt":["1"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"],"Sec-Fetch-Site":["cross-site"],"Sec-Fetch-User":["?1"],"Accept-Language":["en-US,en;q=0.9"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36"],"Sec-Fetch-Mode":["navigate"]},"tls":{"resumed":false,"version":772,"ciphersuite":4865,"proto":"h2","proto_mutual":true,"server_name":"www..com"}},"common_log":" - - [23/Apr/2020:12:52:55 -0400] \"GET /test.nomedia HTTP/2.0\" 403 0","latency":0.000116576,"size":0,"status":403,"resp_headers":{"Content-Type":[],"Server":["Caddy"]}}

Log:

{"level":"error","ts":1587660775.1255589,"logger":"http.log.access.log2","msg":"handled request","request":{"method":"GET","uri":"/test.nomedia","proto":"HTTP/2.0","remote_addr":":35574","host":"www..com","headers":{"Dnt":["1"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"],"Sec-Fetch-Site":["cross-site"],"Sec-Fetch-User":["?1"],"Sec-Fetch-Dest":["document"],"Accept-Encoding":["gzip, deflate, br"],"Pragma":["no-cache"],"Cache-Control":["no-cache"],"Accept-Language":["en-US,en;q=0.9"],"Sec-Fetch-Mode":["navigate"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36"]},"tls":{"resumed":false,"version":772,"ciphersuite":4865,"proto":"h2","proto_mutual":true,"server_name":"www..com"}},"common_log":" - - [23/Apr/2020:12:52:55 -0400] \"GET /test.nomedia HTTP/2.0\" 403 0","latency":0.000116576,"size":0,"status":403,"resp_headers":{"Content-Type":[],"Server":["Caddy"]}}

Ah, okay – thanks for filling out the rest of the Caddyfile.

Well, only access logs go to the access log. Right now the access logs are all INFO or ERROR level I think, but if they ever emit a debug log, that is the option to toggle that (for that site only).

We also don’t have a lot of debug logging right now, we mostly add it where it’s actually needed by us or users. Do you need more debug logs? Where?

I was hoping to be able to see the authorized user from authbasic.

Nevermind. I see the authorization is just in base64. Easy enough. Thanks.

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