Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 16 章 Logging 日志

目录

16.1. rsyslog
16.1.1. rsyslog.conf
16.2. logrotate - rotates, compresses, and mails system logs
16.2.1. /etc/logrotate.conf
16.2.2. /etc/logrotate.d/
16.3. syslog-ng
16.4. syslog, klogctl - read and/or clear kernel message ring buffer; set console_loglevel
16.4.1. /etc/sysconfig/syslog
16.4.2. /etc/syslog.conf
16.4.3. logger
16.4.4. To Log Messages Over UDP Network
16.5. 挂载日志卷
16.5.1. 子卷挂载
16.5.2. 使用过个子卷
16.5.3. /etc/fstab配置

16.1. rsyslog

www.rsyslog.com

目前rsyslog已经成为Linux标配之日程序,默认会安装,如果没有安装请使用下面命令安装。


yum install rsyslog
	    
		

16.1.1. rsyslog.conf

	
$ cat /etc/rsyslog.conf 
#  /etc/rsyslog.conf	Configuration file for rsyslog.
#
#			For more information see
#			/usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
#
#  Default logging rules can be found in /etc/rsyslog.d/50-default.conf


#################
#### MODULES ####
#################

$ModLoad imuxsock # provides support for local system logging
$ModLoad imklog   # provides kernel logging support
#$ModLoad immark  # provides --MARK-- message capability

# provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514

# provides TCP syslog reception
#$ModLoad imtcp
#$InputTCPServerRun 514

# Enable non-kernel facility klog messages
$KLogPermitNonKernelFacility on

###########################
#### GLOBAL DIRECTIVES ####
###########################

#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

# Filter duplicated messages
$RepeatedMsgReduction on

#
# Set the default permissions for all log files.
#
$FileOwner syslog
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
$PrivDropToUser syslog
$PrivDropToGroup syslog

#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog

#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf