Linux下的syslog和/var/log

[日期:2012-07-05]

来源:Linux社区

作者:myownstars

[字体:大 中 小]

Syslog is the general standard (IETF) for logging system and program messages in the Linux environment.

This service constitutes the system log daemon, where any program can do its logging (debug, security, normal operation) through in addition the Linux kernel messages.

--该服务由其daemon进程/sbin/syslogd维护,可通过如下命令启动

1 service syslog start

2 /etc/init.d/syslog start

--配置文件为/etc/sysconfig/syslog,大致结构如下;其中klogd负责捕获kernel日志信息

# Options to syslogd

# -m 0 disables 'MARK' messages.

# -r enables logging from remote machines

# -x disables DNS lookups on messages recieved with -r

# See syslogd(8) for more details

SYSLOGD_OPTIONS="-m 0"

# Options to klogd

# -2 prints all kernel oops messages twice; once for klogd to decode, and

# once for processing with 'ksymoops'

# -x disables all klogd processing of oops messages entirely

# See klogd(8) for more details

KLOGD_OPTIONS="-x"

#

SYSLOG_UMASK=077

# set this to a umask value to use for all log files as in umask(1).

# By default, all permissions are removed for "group" and "other".

In principle, the logs handled by syslog are available in the /var/log/ directory on Linux system:

# ls /var/log

acpid            cron.1     maillog.3         rpmpkgs.3         spooler.3

anaconda.log     cron.2     maillog.4         rpmpkgs.4         spooler.4

anaconda.syslog  cron.3     messages          sa                squid

anaconda.xlog    cron.4     messages.1        samba             tallylog

audit            cups       messages.2        scrollkeeper.log  vbox

boot.log         dmesg      messages.3        secure            wtmp

boot.log.1       faillog    messages.4        secure.1          Xorg.0.log

boot.log.2       gdm        Oracle-validated  secure.2          Xorg.0.log.old

boot.log.3       httpd      pm                secure.3          YaST2

boot.log.4       lastlog    ppp               secure.4          yum.log

btmp             mail       prelink           setroubleshoot

conman           maillog    rpmpkgs           spooler

conman.old       maillog.1  rpmpkgs.1         spooler.1

cron             maillog.2  rpmpkgs.2         spooler.2

where some of the logs are dumped under a subdirectory like cups, samba, httpd. Among the logs under /var/log the /var/log/messages is the most common one as the kernel / core system logs are held there. The kernel modules generally dumps there too. So, for problem diagnosis / monitoring the /var/log/messages is the primary log file to examine.

--syslog产生的日志位于/var/log目录下,其中messages是最常用到的,记录startup信息等

The logs are rotated every week (renaming the existing log to filename.number order):

# ls -l /var/log/messages*

-rw------- 1 root root 1973 Jun 10 15:07 /var/log/messages

-rw------- 1 root root 10866 Jun 6 04:02 /var/log/messages.1

-rw------- 1 root root 19931 May 30 04:02 /var/log/messages.2

-rw------- 1 root root 238772 May 23 04:02 /var/log/messages.3

-rw------- 1 root root 171450 May 14 18:29 /var/log/messages.4

Rsyslogd可以看作是syslogd的改良版,可通过man 8 rsyslogd查看详细信息。

以下是最常见的/var/log日志介绍

/var/log/messages – Contains global system messages, including the messages that are logged during system startup. There are several things that are logged in /var/log/messages including mail, cron, daemon, kern, auth, etc.

/var/log/dmesg – Contains kernel ring buffer information. When the system boots up, it prints number of messages on the screen that displays information about the hardware devices that the kernel detects during boot process. These messages are available in kernel ring buffer and whenever the new message comes the old message gets overwritten. You can also view the content of this file using the dmesg command.

/var/log/auth.log – Contains system authorization information, including user logins and authentication machinsm that were used.

/var/log/boot.log – Contains information that are logged when the system boots

/var/log/daemon.log – Contains information logged by the various background daemons that runs on the system

/var/log/dpkg.log – Contains information that are logged when a package is installed or removed using dpkg command

/var/log/kern.log – Contains information logged by the kernel. Helpful for you to troubleshoot a custom-built kernel.

/var/log/lastlog – Displays the recent login information for all the users. This is not an ascii file. You should use lastlog command to view the content of this file.

/var/log/maillog /var/log/mail.log – Contains the log information from the mail server that is running on the system. For example, sendmail logs information about all the sent items to this file

/var/log/user.log – Contains information about all user level logs

/var/log/Xorg.x.log – Log messages from the X

/var/log/alternatives.log – Information by the update-alternatives are logged into this log file. On Ubuntu, update-alternatives maintains symbolic links determining default commands.

/var/log/btmp – This file contains information about failed login attemps. Use the last command to view the btmp file. For example, “last -f /var/log/btmp | more”

/var/log/cups – All printer and printing related log messages

/var/log/anaconda.log – When you install Linux, all installation related messages are stored in this log file

/var/log/yum.log – Contains information that are logged when a package is installed using yum

/var/log/cron – Whenever cron daemon (or anacron) starts a cron job, it logs the information about the cron job in this file

/var/log/secure – Contains information related to authentication and authorization privileges. For example, sshd logs all the messages here, including unsuccessful login.

/var/log/wtmp or /var/log/utmp – Contains login records. Using wtmp you can find out who is logged into the system. who command uses this file to display the information.

/var/log/faillog – Contains user failed login attemps. Use faillog command to display the content of this file.

linux var log管理,Linux下的syslog和/var/log相关推荐

  1. linux ppp用户管理,linux下ppp拨号上网

    转帖 如何用 Linux 拨号上网 一.Linux 上的 PPP Linux 中已经包括了点对点协议PPP,其主体是 pppd ,如果你已经使用过 Windows95 或 NT 的拨号网络,那么你已经 ...

  2. linux虚拟地址空间管理,Linux内存管理4---虚拟地址空间管理

    1.前言 本文所述关于内存管理的系列文章主要是对陈莉君老师所讲述的内存管理知识讲座的整理. 本讲座主要分三个主题展开对内存管理进行讲解:内存管理的硬件基础.虚拟地址空间的管理.物理地址空间的管理. 本 ...

  3. linux应用与管理,Linux操作系统应用与管理

    本书从实际应用的角度出发,以RedHat Linux 9为操作环境,介绍了使用和管理Linux的各种常规操作和技巧.主要内容包括Linux的安装配置.桌面应用.文件目录管理.用户管理.网络管理.安全管 ...

  4. linux组权限管理,Linux组管理和权限管理

    ⒈Linux组基本介绍 1)在Linux中的每个用户必须属于一个组,不能独立于组外. 2)Linux中每个文件都有所有者.所在组.其它组的概念 ①所有者 一般(默认)为文件的创建者,谁创建了该文件,就 ...

  5. linux系统密码管理,Linux使用密码管理工具pass管理密码的方法

    在Linux系统操作中,使用的密码多了反而记不过来,而且也容易记错,如果使用密码管理工具来管理的话会轻松很多,下面小编就给大家介绍一款实用的密码管理工具pass,一起来学习下pass的使用吧. 对于那 ...

  6. linux软件包怎么管理,Linux之软件包管理

    Linux之软件包管理 软件包管理有一般有3种机制:源代码方式.RPM.YUM 软件包的组成格式与存放路径: 1.二进制程序 主要存放的路径:/bin, /sbin, /usr/bin, /usr/s ...

  7. linux文件操作管理,linux 文件管理操作入门

    mkdir -p /root/kali/bp/shell  一路创建文件夹直到生成文件夹shell,中间没有kali文件夹的话也会自动创建生成 tar解压缩 范例一:将整个 /etc 目录下的文件全部 ...

  8. linux通用自启动管理,linux下通过xinetd服务管理 rsync 实现开机自启动

    1.1 xinetd服务配置 1.1.1 检查xinetd服务是否安装 [root@backup ~]# rpm -qa xinetd [root@backup ~]# rpm -ql xinetd ...

  9. linux 查看磁盘管理,linux下的磁盘管理

    1.磁盘管理 磁盘是我们日常生活中最主要的存储介质,在工业领域同样有着大量的使用,对于一块硬盘,我们并不能直接读取上面的数据,因为磁盘上的是二进制数据,有磁性代表着1,没磁性代表着0,读取数据是计算机 ...

最新文章

  1. Android 实现TextView后面跟随一个高度和宽度固定的ImageView
  2. Wordpress插件检测机制原理
  3. python机器学习常用包
  4. 数据表的新建 修改 删除 mysql
  5. JSK-16500 金币【模拟】
  6. 开源中文bi_odoo:免费开源ERP入门与实践
  7. echarts 地图添加纹理图片
  8. VB如何自动保存_VB编程——菜单栏设计教程
  9. 阿里maven私服配置和作品上传
  10. 推荐好用的两个搜索下载书籍网站
  11. 路由器密码破解:路由器登陆密码破解方法(仅用于丢失密码后
  12. numpy.take()用法总结
  13. 【数学建模】数学建模学习5---图与网络(例题+matlab代码实现)
  14. 一起学习如何使用Photoshop绘制像素图片
  15. Flink实践 | 360 政企安全基于 Flink 的 PB 级数据即席查询实践
  16. 深度学习1:二分类问题
  17. 实验输出菱形图案 (5 分)
  18. 奇数下标都是奇数或者偶数下标都是偶数(Java)
  19. mysql建表按 t分开_记一次MYSQL建表失败得bug
  20. 【Python技能树共建】Beautiful Soup

热门文章

  1. Java 面试如何坐等 offer?
  2. 任正非:美国迟早会爱上华为
  3. 3.15 曝光:40 亿 AI 骚扰电话和 11 家合谋者
  4. 零基础程序员如何花 8 个月时间获得特斯拉实习机会?
  5. 一文揭秘知乎是如何搞 AI 的 | 技术头条
  6. Linux 4.20 发布!35 万行代码都更新了啥?
  7. 微软智能云Azure Kubernetes容器服务落地中国,开启预览
  8. 蚂蚁金服 TRaaS 技术风险防控平台解密
  9. 佛系青蛙外挂横行,20 元可买 21 亿无限三叶草
  10. 天天 Java、C/C++,可这五种编程语言你知道吗?