I am currently trying to configure Caddy from FrankenPHP running Laravel Octane. I am confused about the access logs because even if it is “wrapped” under json, I’m only seeing the following logs in my docker container’s stderr
Ultimately, I’m moving from Nginx to Caddy and I want to format the logs as JSON and add an additional field as well called “origin” with the value “caddy”.
So I’ve been trying to get the logs to output JSON for the past couple of hours.
It turns out, if my output is “stderr”, the logs come out as shown in the image above even when i specify “format json”.
When I change the output to output file /sample.log, I can see it properly outputs the JSON log here. It could be that if I specify “stderr” as the output, it defaults to something else (guessing “console” from the documentation) and ignores my current format setting.
I’ve resorted to rebuilding xcaddy with transform-encoder and is currently a work in progress… but I really just want to output JSON to my stderr…
Do you have anything else running in that container or something? That looks like the octane output, not the Caddy output. It’s probably eating the Caddy output if you write it to stderr. I don’t really know what they do with Caddy’s output. I would hope it’s retained because Caddy’s runtime logs are important to see deprecation warnings and config errors etc. You’ll need to ask for help with them for that.
Hi Francis, yes, it looks like you’re right. It is the output of php artisan octane:frankenphp. I’ve given up trying to output JSON here and probably just run an Nginx proxy to caddy for now… which was mentioned here https://laravel.com/docs/11.x/octane#serving-your-application-via-nginx
but seems so redundant since there is already Caddy built into FrankenPHP.
You can have Caddy output its logs to file tho. The log global option configures runtime logs, whereas the log directive inside your site block configures access logs. That should be sufficient for you.
I need it to output to stderr though because we’re using ECS Fargate containers. It automatically puts all stderr logs into cloudwatch and that is acutally the goal for our logs.