在Debian系统中,syslog的日志级别可以通过修改/etc/rsyslog.conf
文件或/etc/rsyslog.d/
目录下的配置文件来设置。以下是设置日志级别的步骤:
打开终端。
使用文本编辑器打开/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
。你可以根据需要选择合适的日志级别。
rsyslog.conf
文件中添加类似的行。例如,要将Apache Web服务器的日志级别设置为crit
,可以添加以下行:authpriv.* /var/log/apache2/other_vhosts_access.log
local0.* /var/log/apache2/other_vhosts_access.log
然后,在/etc/rsyslog.d/
目录下创建一个新的配置文件,例如apache2.conf
,并添加以下内容:
local0.crit /var/log/apache2/error.log
保存并关闭rsyslog.conf
文件。
重启rsyslog服务以应用更改:
sudo systemctl restart rsyslog
现在,Debian系统中的syslog日志级别已经根据你的设置进行了调整。