Linux配置日志级别,linux之日志篇

rsyslog

linux系统中用来实现日志功能的服务称为rsyslog,是早期syslog服务的增强版本,默认情况下是自动安装,并启动的。

1、启动服务

[root@37-test log]# service rsyslog start

2、配置文件

[root@37-test log]# more /etc/rsyslog.conf

基本格式:

facility.prioritylog_location

[root@37-test log]# more /etc/rsyslog.conf  |grep -v ^# |grep -v ^$

$ModLoad imuxsock.so# provides support for local system logging (e.g. via logger command)

$ModLoad imklog.so# provides kernel logging support (previously done by rklogd)

$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

*.info;mail.none;authpriv.none;cron.none                /var/log/messages

authpriv.*    //*表示任意级别,none就是没有级别,不记录     /var/log/secure

mail.*          -/var/log/maillog    //-表示不等待磁盘同步,确认操作是否已经写入到磁盘中,

cron.*                                                  /var/log/cron

*.emerg                                                 *

uucp,news.crit                                          /var/log/spooler

local7.*                                                /var/log/boot.log

plr@10.40.0.100表示使用udp协议将消息存储到指定远程服务器上。

user@@10.40.0.200表示使用TCP协议将消息存储到指定远程服务器上。

3、日志存放位置

[root@37-test log]# ls /var/log

anaconda.ifcfg.logcupsmessages-20170108  spooler-20170101

anaconda.log          dmesgnprobespooler-20170108

anaconda.program.log  dmesg.oldntopngtallylog

anaconda.storage.log  dracut.logntpstatswpa_supplicant.log

anaconda.syslog       dracut.log-20130101  pm-powersave.log   wtmp

anaconda.xloggdmpppxferlog

anaconda.yum.loghttpdpuppetxferlog-20161218

auditiptrafredisxferlog-20161225

boot.log              lastlogsaltxferlog-20170101

btmp                  maillogsambaxferlog-20170108

btmp-20170101         maillog-20161218     secure             Xorg.0.log

centomaillog-20161225     secure-20161218    Xorg.0.log.old

ConsoleKitmaillog-20170101     secure-20161225    yum.log

cron                  maillog-20170108     secure-20170101    yum.log-20140610

cron-20161218         messages             secure-20170108    yum.log-20150101

cron-20161225         messages-20161218    spooler            yum.log-20160101

cron-20170101         messages-20161225    spooler-20161218   yum.log-20170101

cron-20170108         messages-20170101    spooler-20161225

4、实时监控日志信息

[root@37-test log]# tail /var/log/messages-20170108 -f

Jan  8 03:01:23 37-test puppet-agent[17734]: Caching catalog for 37-test

Jan  8 03:01:24 37-test puppet-agent[17734]: Applying configuration version '1483815681'

Jan  8 03:01:59 37-test puppet-agent[17734]: (/Stage[main]/Common/Exec[hot_fix_for_fms_audio_config]/returns) executed successfully

Jan  8 03:01:59 37-test puppet-agent[17734]: (/Stage[main]/Common/Exec[hot_fix_for_CourswareBussiness.php]/returns) executed successfully

Jan  8 03:01:59 37-test puppet-agent[17734]: (/Stage[main]/Common/Exec[hot_fix_for_fms_video_config]/returns) executed successfully

5、日志消息的来源-facility

rsyslog通过facility概念来定义日志消息的来源,以方便对日志进行分类。

-kern内核消息

-user用户级消息

-mail邮件系统消息

-daemon系统服务消息

-auth认证系统消息

-lpr打印系统消息

-syslog日志系统自身消息

-authpriv权限系统消息

-cron计划定时任务消息

-news新闻系统消息

-uucpuucp系统消息

-ftpftp服务消息

6、priority/serverity level(日志优先级,级别)

-emergency系统已经不可用

-alert必须立即处理

-critical严重错误

-error错误

-warning警告

-notice正常信息,但较为重要

-informational正常信息

-debugdebug信息

日志级别包括最大级别和最小级别

最大级别:指记录日志的最低等级是什么,换句话说如果定义了日志的最大级别是error,那么他的意思就是说只记录error及以上级别的错误日志。

最小级别:和最大级别正好相反,并且也不常用。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值