systemdsystemd-journald

systemd - can out redirect logs to a file and journald


I have a ubunut machine running in AWS and want to bring the docker daemon logs to AWS Cloudwatch. Per default docker daemon is started via systemd on ubuntu and logs to the journal, and I want to keep docker logs in the journal.

But aws-cloudwatch-logs-agent does not support sending logs for a service from the journal to cloudwatch, and I therefore need a log file.

Thats why I am wondering if I can configure a systemd service to log to a file and to the journal?

I can log to a file with:

[Service]
StandardOutput=append:/var/log/dockerd.log
StandardError=append:/var/log/dockerd.log

But then now logs appear in the journal ... any ideas?


Solution

  • Keep the service logging to journal (i.e. default settings), but have a second service that creates the text-file logs from journal logs.