Caddy Logs Outputting to RSysLog/Azure Log Analytics

Hi Franics, yes it is running as a service

systemctl status caddy

● caddy.service - Caddy
   Loaded: loaded (/lib/systemd/system/caddy.service; enabled; vendor preset: enabled)
   Active: active (running) (Result: exit-code) since Mon 2022-02-14 03:14:21 UTC; 1 day 17h ago
     Docs: https://caddyserver.com/docs/
 Main PID: 3131 (caddy)
    Tasks: 8 (limit: 447)
   CGroup: /system.slice/caddy.service
           └─3131 /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
journalctl -u caddy --no-pager | less +G

Feb 15 15:39:56 caddyvm-vm-dev-0 caddy[3131]: {"level":"info","ts":1644939596.0619006,"logger":"http.log.access","msg":"handled request","request":{"remote_addr" [...]
Feb 15 20:06:08 caddyvm-vm-dev-0 caddy[3131]: {"level":"info","ts":1644955568.668636,"logger":"admin.api","msg":"received request","method":"GET","host":"localhost:2019","uri":"/config/","remote_addr":"[curl]","headers":{"Accept":["*/*"],"User-A
gent":["curl/7.58.0"]}}
cat /lib/systemd/system/caddy.service

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target

[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /mnt/caddyvmdata/Caddyfile
ExecReload=/usr/bin/caddy reload --config /mnt/caddyvmdata/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
SyslogFacility=local4
SyslogIdentifier=syslogazuremonitor


[Install]
WantedBy=multi-user.target

I have edited the --config paths and added SyslogFacility and SyslogIdentifier lines above, and it’s coming into Azure :ok_hand:

My question now, is there a way I can edit this while installing the service in a non-interactive manner? Currently that .sh script looks a bit like this

sudo apt update 
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https 
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo apt-key add - 
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
caddy version
caddy reload --config /mnt/caddyvmdata/Caddyfile