A simple Bash script to view and stream Dockerized Caddy logs in a clean, colorized, and filtered format using jq.
When running Caddy in Docker, the default logs can be hard to read or cluttered with specific repetitive messages. Pretty Caddy Logs provides a streamlined way to:
- Stream logs in real-time.
- Colorize JSON output for better readability.
- Seamlessly handle both JSON and plain-text (e.g., startup errors or s6-rc logs).
- Filter out common noise.
This script is ideal for developers and sysadmins who want a "pretty" tail of their Caddy logs without manually typing complex docker logs | jq pipes every time. It's especially useful for debugging configuration issues where you need to see both the container's startup output (text) and Caddy's structured logs (JSON).
- No
sudoRequired: Works with your standard user (provided you are in thedockergroup). - Smart Filtering: Automatically hides "aborting with incomplete response" messages which often clutter logs during normal HTTP/2 or WebSocket operations.
- Hybrid Log Support: Uses
try/catchinjqto print raw strings if the log line isn't valid JSON, ensuring you don't miss critical startup or system errors. - Colorized Output: High-contrast log viewing.
- Docker: The container must be named
Caddy(or you can edit the script to match your container name). - jq: A lightweight and flexible command-line JSON processor.
-
Clone this repository:
git clone https://github.com/Smiie-2/Pretty-Caddy-Logs.git cd Pretty-Caddy-Logs -
Make the script executable:
chmod +x caddy_jq_log.sh
Simply run the script:
./caddy_jq_log.shTo exit the stream, press Ctrl+C.
Note: Ensure your Caddy container is named Caddy or modify the docker logs -f Caddy line in the script to match your environment.