在Ubuntu系统中,syslog的日志级别可以通过修改/etc/rsyslog.conf
文件或/etc/rsyslog.d/
目录下的配置文件来设置。以下是设置syslog日志级别的步骤:
打开终端。
使用文本编辑器打开/etc/rsyslog.conf
文件。例如,使用nano编辑器,输入以下命令:
sudo nano /etc/rsyslog.conf
rsyslog.conf
文件中,找到类似于以下的行:# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
#
字符)并更改日志级别。例如,如果您希望将内核消息的日志级别设置为alert
,则可以将其更改为:kern.alert /dev/console
rsyslog支持以下日志级别,从最低到最高:emerg
、alert
、crit
、err
、warning
、notice
、info
和debug
。
mail.* -/var/log/mail.log
并将其更改为所需的日志级别,如:
mail.alert -/var/log/mail.log
保存并关闭rsyslog.conf
文件。
重启rsyslog服务以使更改生效:
sudo systemctl restart rsyslog
现在,您的Ubuntu系统应该已经根据您在rsyslog.conf
文件中所做的更改设置了新的syslog日志级别。