Daemon log with brew services caddy

1. Caddy version (caddy version):

v2.0.0

2. How I run Caddy:

brew services start caddy

a. System environment:

macOS catalina

b. Command:

brew services start caddy

c. Service/unit/compose file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>homebrew.mxcl.caddy</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/opt/caddy/bin/caddy</string>
      <string>run</string>
      <string>--config</string>
      <string>/usr/local/etc/Caddyfile</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>

d. My complete Caddyfile or JSON config:

paste config here, replacing this text
DO NOT REDACT anything except credentials

3. The problem I’m having:

this is global options

{
  debug
  # acme_ca "https://acme-staging-v02.api.letsencrypt.org/directory"
}
import sites-enabled/*.caddy

log directive is for site, how to view daemon log when started caddy with brew services.

everytime i want to see the log, i have to stop caddy service, and copy commands from plist or type

caddy run --config /usr/local/etc/Caddyfile

A quick Google search gave me this answer:

I don’t use a Mac so your mileage may vary.

Please note that you’re using an older version of Caddy, please upgrade to v2.1.1

thanks,

you remind me i can customize the stdout, stderr path.

just send a pr, before pr merged,
here is my solution:

you can just go to brew --cellar caddy folder and edit homebrew.mxcl.caddy.plist and add

    <key>StandardOutPath</key>
    <string>/usr/local/var/log/caddy.log</string>
    <key>StandardErrorPath</key>
    <string>/usr/local/var/log/caddy.log</string>

after RunAtLoad.

then brew services restart caddy

tail -f /usr/local/var/log/caddy.log

1 Like