linux之系统日志与日志文件


扔掉日志

轮换日志文件

存档日志文件

2.linux日志

特殊日志文件

/var/log/wtmp包含用户登录系统和退出系统的记录,也包含了表明系统核实启动或者关机的记录项(二进制形式存储)。使用last命令解读这些信息。

/var/log/lastlog只记录每个用户上次登录的时间。是一个稀疏的二进制文件,以UID作为索引.

内核和启动日志:

dmesg命令-----输出重定向到/var/log/dmesg 或者/var/log/boot.msg(suse)

klogd守护进程----将日志发送到/var/log/messages

dmesg -n 2

initlog-----

logrotate:管理日志文件:savelog

 

syslog:系统事件的日志程序

体系结构:

  • syslogd,日志守护进程(以及配置文件/etc/syslog.conf)
  • openlog,将消息提交给syslogd的库例程
  • logger,一条从shell提交日志记录项的用户级命令

syslogd进程ID写入到/var/run/syslogd.pid

修改配置文件后,发送一个挂起信号:kill -HUP   `/bin/cat /var/run/syslogd.pid`

配置文件:

1.单机

#syslog.conf file for small network or stand-alone machines

 

#emergences:tell everyone who is logged on 

*.merg  *

#important message

*.waring:daemon,auth.info;user:none /var/log/messages

#print errors

lpr.debug  /var/log/lpd.errs

2.网络客户机

网络客户机通常把重要的信息转发给中央日志记录主机:

#syslog.conf file for nonmaster machines

#emergencies:tell everyone who is logged in

*.emerg;user.none  *

#Forwar important messages to the center logger

*.waring;lpr.local1.none   @netloghost

daemon,auth.info  @netloghost

#send some local stuff to the center logger too

local2.info;local7.debug    @netloghost

#keep printer errors local

lpr.debug  /var/log/lpd-errs

#sudo logs to local2 ---keep a copy here too

local2.info  /var/log/sudo.log

#keep kernal messager local

kern.info  /var/log/kern.log

 

3.中央日志记录主机。---大约7000台主机构成的一个中等规模网络上的中央安全日志主机

#syslog.conf file for master logging host

#Emergencies to the console and log file,with timing marks

*.emerg  /dev/console

*.err;kern,mark.debug;auth.notice  /dev/console

*.err;kern,mark.debug;user.none  /var/log/console.log

auth.notice  /var/log/console.log

 

#send non-emergency messages to the usual log files

*.err;user.none;kern.debug  /var/log/messages

daemon,auth.notice;mail.crit  /var/log/messages

lpr.debug  /var/log/lpd-errs

mail.debug  /var/log/mail.log

 

#local authorization stuff like sudo and npasswd

local2.debug  /var/log/sudo.log

local2.alert  /var/log/sudo-errs.log

auth.info  /var/log/auth.log

 

#other local stuff

local4.notice  /var/log/da.log

local4.debug  /var/log/tcp.log

#user stuff 

user.info  /var/log/user.log

 

分析日志文件:

swatch

logcheck

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM