1. 程式人生 > >CentOS 7 修改日誌時間戳格式

CentOS 7 修改日誌時間戳格式

times efault 默認 pre systemctl oot ESS hostname for

默認的時間戳格式是

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

看著不是很方便,現修改為以下格式

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

修改 /etc/rsyslog.conf

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

然後重啟 rsyslog 服務

systemctl restart rsyslog.service


CentOS 7 修改日誌時間戳格式