CentOS 7 修改日誌時間戳格式

默認的時間戳格式是
bash

Jul 14 13:30:01 localhost systemd: Starting Session 38 of user root.

看着不是很方便,現修改成如下格式
ide

2018-07-14 13:32:57 desktop0 systemd: Starting System Logging Service...

修改 /etc/rsyslog.conf rest

# Use default timestamp format
#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat # 這行是原來的將它註釋,添加下面兩行
$template CustomFormat,"%$NOW% %TIMESTAMP:8:15% %HOSTNAME% %syslogtag% %msg%\n"
$ActionFileDefaultTemplate CustomFormat

而後重啓 rsyslog 服務orm

systemctl restart rsyslog.service
相關文章
相關標籤/搜索