Caddy v2 Access log file doesn't show any entry

1. Caddy version (caddy version):


2. How I run Caddy:

Caddy runs as local reverse proxy for and it works fine.

a. System environment:

Ubuntu 20.04, systemd

b. Command:

Paste command here.
systemctl start caddy.service

#### c. Service/unit/compose file:
<!-- If using Docker/systemd/Kubernetes/make etc. -->

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

#### d. My complete Caddyfile or JSON config:

Paste config here, replacing this text.
Use caddy fmt to make it readable.
DO NOT REDACT anything except credentials.
Make sure the backticks stay on their own lines.

root@pur:~# cat /etc/caddy/Caddyfile {
        log {
            output file /tmp/caddy/nc.log
            format filter {
               wrap console
               fields {
                  request>headers>Authorization delete

### 3. The problem I'm having:
<!-- What are you trying to do, and what isn't working? Please describe the issue thoroughly enough so that anyone can reproduce the exact behavior you're seeing. Be as specific as possible. DO NOT USE WEB BROWSERS; use "curl -v" instead. -->
The problem is the access log file doesn't get any logs. The whole path to /tmp/caddy/nc.log has 777 permissions. 

### 4. Error messages and/or full log output:
<!-- Please **DO NOT REDACT** any information except credentials. Leave domain names intact! -->
<!-- Please **DO NOT POST TRUNCATED LOG LINES** as systemd is notorious for this. -->
<!-- Please **DO NOT USE WEB BROWSERS.** Use curl -v instead. -->
I don't see any messages about /tmp/caddy/nc.log in /var/log/messages or in journalctl -u caddy.service

### 5. What I already tried:
<!-- Show us what effort you've put in to solving the problem. Be specific -- people are volunteering their time to help you! Low effort posts are not likely to get good answers! -->
If i only use 'log" keyword in Caddyfile, i do see access logs in journalctl -u caddy.service

### 6. Links to relevant resources:

Please fix your post’s formatting. Make sure code sections start and end with ``` on their own lines.

Ah - the problem is that the systemd service uses PrivateTmp=true so to Caddy, the location isn’t actually /tmp, but actually some other subdirectory deeper inside /tmp.

Look for a directory like /tmp/systemd-private-<somehash>-caddy.service-<somehash> and you should find the log file in there.

The purpose of PrivateTmp is to isolate temp files for the service from every other app on the system, for security and to avoid apps stepping on eachother’s toes.

Alternatively if you want to opt out of that, you can run sudo systemctl edit caddy and add PrivateTmp=false. This lets you set some overrides to the built-in systemd config without editing the actual systemd config managed by the debian package.

And finally, you could pick a different location for the logs, like /var/log/caddy, in which case there won’t be this transparent rewrite of the path.

Hi, many thanks, yes, I did find the logs as you indicated. Now, is there a way to make the caddy log file more readable?

That’s vague. What’s the problem?

See here for an explanation as to why Caddy logs with JSON:

I’m referring to formatting when reading it with “cat”. How can I display the nice json formatting?

You can use the tool jq

Thank you, really appreciated.

1 Like

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