1. Caddy version (caddy version
):
v2.4.1 h1:kAJ0JB5Xk5gPdTH/27S5cyoMGqD5lBAe9yZ8zTjVJa0=
2. How I run Caddy:
I’m just running a simple file server with the command and Caddyfile below.
a. System environment:
Windows 10 x64
b. Command:
caddy run -watch
c. Service/unit/compose file:
N/A
d. My complete Caddyfile or JSON config:
localhost
root * content
file_server
templates
3. The problem I’m having:
I’m running a very simple file server with Caddy but what bothers me is the structured JSON logging data in log output. Each line has some JSON at the end and some lines, like HTML template errors have very big blocks of it that make everything kind of unreadable.
This looks especially bad with line wrapping as is the default behavior on many terminals.
I would like to just disable printing of full JSON data at the end of each log message.
4. Error messages and/or full log output:
Here’s an example of what I mean. These are just the default messages that are printed when running and terminating Caddy, along with an HTML template error.
If you look at this with line wrapping on it will be particularly hard to read.
2021/06/02 23:24:38.681 INFO using adjacent Caddyfile
2021/06/02 23:24:38.682 WARN input is not formatted with 'caddy fmt' {"adapter": "caddyfile", "file": "Caddyfile", "line": 5}
2021/06/02 23:24:38.689 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2021/06/02 23:24:38.689 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc0000a1650"}
2021/06/02 23:24:38.689 INFO http server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS {"server_name": "srv0", "https_port": 443}
2021/06/02 23:24:38.690 INFO http enabling automatic HTTP->HTTPS redirects {"server_name": "srv0"}
2021/06/02 23:24:38.702 INFO tls cleaning storage unit {"description": "FileStorage:C:\\Users\\jeffr\\AppData\\Roaming\\Caddy"}
2021/06/02 23:24:38.705 INFO tls finished cleaning storage units
2021/06/02 23:24:38.729 INFO pki.ca.local root certificate is already trusted by system {"path": "storage:pki/authorities/local/root.crt"}
2021/06/02 23:24:38.731 INFO http enabling automatic TLS certificate management {"domains": ["localhost"]}
2021/06/02 23:24:38.734 WARN tls stapling OCSP {"error": "no OCSP stapling for [localhost]: no OCSP server specified in certificate"}
2021/06/02 23:24:38.735 INFO autosaved config (load with --resume flag) {"file": "C:\\Users\\jeffr\\AppData\\Roaming\\Caddy\\autosave.json"}
2021/06/02 23:24:38.735 INFO serving initial configuration
2021/06/02 23:24:40.853 ERROR http.log.error template: /layout.html:12: function "templateError" not defined {"request": {"remote_addr": "[::1]:2029", "proto": "HTTP/2.0", "method": "GET", "host": "localhost", "uri": "/layout.html", "headers": {"Cookie": ["session-id=s%3AKEWFiVG5t7QmRngIKCse2cQrhkGsd022.nvtq1ZXx8tC8H3efQxsP9fEe1gHn0XkgoLCZzZgnttM"], "Sec-Ch-Ua-Mobile": ["?0"], "Sec-Fetch-Site": ["none"], "Sec-Fetch-User": ["?1"], "Accept-Encoding": ["gzip, deflate, br"], "Sec-Ch-Ua": ["\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\""], "Upgrade-Insecure-Requests": ["1"], "Sec-Fetch-Mode": ["navigate"], "Sec-Fetch-Dest": ["document"], "Accept-Language": ["en-US,en;q=0.9,fr;q=0.8"], "Dnt": ["1"], "User-Agent": ["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"], "Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"], "Cache-Control": ["max-age=0"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4865, "proto": "h2", "proto_mutual": true, "server_name": "localhost"}}, "duration": 0.1319475, "status": 500, "err_id": "78jiqpg0p", "err_trace": "templates.(*Templates).executeTemplate (templates.go:315)"}
2021/06/02 23:24:42.329 INFO shutting down {"signal": "SIGINT"}
2021/06/02 23:24:42.329 WARN exiting; byeee!! 👋 {"signal": "SIGINT"}
2021/06/02 23:24:42.355 INFO tls.cache.maintenance stopped background certificate maintenance {"cache": "0xc0000a1650"}
2021/06/02 23:24:42.370 INFO admin stopped previous server {"address": "tcp/localhost:2019"}
2021/06/02 23:24:42.370 INFO shutdown complete {"signal": "SIGINT", "exit_code": 0}
5. What I already tried:
format console
says it’s supposed to be human readable, but it still appends JSON which is not what I want.
I tried format single_field common_log
but it looks really old fashioned and clunky, and it doesn’t affect stuff like HTTP template errors and the stuff that prints on startup. What I want is simple human readable output, like v1 had, and the default formatter is so close to that except for the JSON dumping.