Separate error and access log

1. The problem I’m having:

Since then I’m using Apache and Nginx. Now I’d like to switch to Caddy because of the h3 support.

I’m wondering how to set up separate error and access logs. I’ve read the documentation on how to do this, but I can’t get my head around it.

Here is what I’ve used until now.

ErrorLog logs/error.log
LogLevel warn

<IfModule mod_log_config.c>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
    CustomLog logs/access.log combined


error_log /var/log/nginx/error.log warn;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;

For Caddy, I understand how to define access log, but I don’t understand how to define a separate access and error log.

2. Error messages and/or full log output:


3. Caddy version:


4. How I installed and ran Caddy:


a. System environment:

Debian 12 bookworm (testing)

d. My complete Caddy config:

domain.tld {
        root * /srv/caddy/domain.tld/public
        encode gzip
        php_fastcgi unix//run/php/php8.2-fpm.sock
        file_server {
                index index.php
        log {
                output file /var/log/caddy/access.log

The log directive (within a site block) is for access logs.

The log global option (within the global options block) is for all other logs.

If you want PHP errors to be captured, then you need to use the capture_stderr option of the php_fastcgi directive.

See the docs for all of the above.

1 Like

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