
我已將 docker 配置為使用 syslog 日誌驅動程式。我的 daemon.json 看起來像這樣:
{
"log-driver": "syslog",
"log-opts": {
"syslog-address": "tcp://192.168.1.10:1514",
"mode": "non-blocking",
"tag": "{{.ImageName}}/{{.Name}}"
}
}
根據docker 文件中 tag 參數,這應該會產生一個包含主機設備的主機名稱的輸出。這不會發生 - 我的日誌看起來像這樣(被截斷):
<27>Dec 22 19:27:44 authelia/authelia/authelia[3693936]: time="2022-12-22T19:27:44-05:00" level=info msg="...
我可以將主機名稱寫入標記參數,但我想在許多機器上使用此配置。我錯過了什麼嗎?
答案1
我想通了這個問題。解決方案是(像往常一樣)閱讀更多文件。
https://docs.docker.com/config/containers/logging/syslog/#options
syslog-format The syslog message format to use. If not specified the local UNIX syslog format is used, without a specified hostname. Specify rfc3164 for the RFC-3164 compatible format, rfc5424 for RFC-5424 compatible format, or rfc5424micro for RFC-5424 compatible format with microsecond timestamp resolution.
如果您不指定格式,它將省略主機名稱。