温馨提示×

centos syslog在哪启动

小樊
37
2026-09-30 02:36:11
栏目: 智能运维

在 CentOS 里,syslog 的“启动”位置和方式取决于系统版本以及你用的是哪种日志服务。


一、CentOS 6 及更早(使用 syslog / rsyslog)

1. 服务名

通常是:

  • syslog
  • 或 rsyslog(更常见)

2. 启动 / 查看状态

service rsyslog status
service rsyslog start
service rsyslog restart

或(旧一点的):

service syslog start

3. 开机自启

chkconfig rsyslog on

4. 配置文件位置

/etc/rsyslog.conf
/etc/sysconfig/rsyslog

二、CentOS 7 / 8 / Stream(使用 systemd + rsyslog / journald)

1. 查看 syslog 服务

CentOS 7+ 默认用 rsyslog(systemd 管理):

systemctl status rsyslog

2. 启动 rsyslog

systemctl start rsyslog

3. 设置开机启动

systemctl enable rsyslog

4. systemd 单元文件位置

/usr/lib/systemd/system/rsyslog.service

三、CentOS 7+ 的“真正 syslog”:journald

CentOS 7 以后,系统日志核心在 systemd-journald:

systemctl status systemd-journald

查看日志:

journalctl

rsyslog 通常只是把 journal 的日志再写一份到 /var/log/messages


四、常见日志文件位置

/var/log/messages   # 系统日志(rsyslog)
/var/log/secure     # 安全/登录日志
/var/log/cron       # 定时任务
/run/log/journal/   # journald 日志

五、快速判断你用的是什么

ps -ef | grep rsyslog
systemctl | grep -E "rsyslog|journald"

如果你能告诉我:

  • CentOS 版本
  • 是 物理机 / 虚拟机 / 容器
  • 是 想开机自启 还是 排查日志不写

我可以直接给你最精确的命令。

0 踩