systemd 文件
[root@node1 ~]# cat /etc/systemd/system/spms-wvp.service
[Unit]
Description=WVP service
[Service]
# 关键配置部分,注意这里的 spms-wvp ,后面需要用
SyslogIdentifier=spms-wvp
StandardOutput=syslog
StandardError=syslog
Type=simple
EnvironmentFile=-/apps/cig/systemd-conf/spms-share
User=cig
Group=cig
ExecStart=/usr/local/java/bin/java $JAVA_OPTS -jar ${SPMS_HOME}/spms-media-wvp-pro-2.6.8.jar --spring.config.location=/apps/cig/config/wvp.yml
ExecStartPost=
Restart=always
RestartPreventExitStatus=1 6 SIGABRT
KillMode=process
LimitNOFILE=104857
LimitNPROC=1048576
[Install]
WantedBy=multi-user.target
配置 rsyslog
[root@node1 ~]# cat /etc/rsyslog.d/spms-wvp.conf
if ($programname == 'spms-wvp') then {
action(type="omfile" file="/apps/logs/spms-wvp.log")
stop
}
spms-wvp 需要和 systemd 文件中 SyslogIdentifier 的值一致
/apps/logs/spms-wvp.log 是具体的日志路径
配置日志轮转
[root@node1 ~]# cat /etc/logrotate.d/spms-wvp
/apps/logs/spms-wvp.log {
copytruncate
dateext
dateformat -%Y%m%d%H
size 1M
rotate 5
compress
delaycompress
createolddir
notifempty
missingok
}