linux日志文件

简介:

下面我给大家介绍一下linux里面的日志文件:

 

    日志一般的服务都包括:访问日志和错误指示;访问日志一般记录服务的运行状态,服务执行了什么操作,都记录在访问日志中;而错误日志通过名字也可理解,到服务遇到错误时,就会把错误的日志记录在错误日志中。


Windows

      像在windows里面我们需要查看日志需要从,“管理”目录下面找到事件查看器,而这些都属于在window日志查看器


Linux

   首先我们要查看我们的linux  里面是否存在sysklogd-1.4.1-44.e15

这个软件包,也就是一些关于日志的一些文件,然后我们进行查看这个软件包

像一些软件包里面带有d都是一些服务软件的包“sysklogd

其中里面有这两个软件包(1)/sbin/klogd 是针对内核产生日志信息

                       dmesg 这个指令可以查看针对内核硬件的信息

                       dmesg | grep -i cpu  可以查看cpu的信息

                       dmesg | grep -imem  可以查看内存的信息

                       dmesg | grep -ietho   可以查看网卡的信息

 

  (2)/sbin/syslogd 是针对系统的服务日志信息

   系统包括:我们平时安装的某些软件,网络设备等

   /sbin/syslogd会产生一个分类的文件而这个分类的文件就是/etc/syslong.conf我们打开这个文件会看到分类文件

   每一行表示一个规则,前一个是一个选择域后一个是动作域 *表示是每个人,动作域就表示我们需要把这些的信息发到哪里去

   选择里面包括应用和级别而动作包括文件每个人@主机名称或地址072056358.png

   前面带(#)都是注释的意思

   不带注释的每一行前面的表示一种应用服务,后面可以跟它的级别,而在应用里面有身份验证计划任务某一种应服务内核打印邮件标志新闻安全用户在安全的情况下我们一般不用的

   .后面跟着级别最低debug info(提醒)  notice(注意),warning warn err error crit (严重)alert emerg panic  由低到高级别

   我们先从第7行开始给大家说明一下:所有应用软件的大于等于info都要被记录下来,除了关于mail 验证计划任务相关的都要寄到这个文件里面 /var/log/messages

     

   第10行 authpriv.*验证这些验证的信息都记录到/var/log/secure

例:我从第四个终端进去,故意输错密码,这是再查看日志文件提示


   第13邮件相关‘-’表示异步,表示等系统空闲了再把信息写到这个文件里面去


   第17计划任务


   第20所有严重的信息发个每一个人


   第23行 UUcp 新闻的大于crit大于这个级别的都会存放到


   我给大家举个例子:我安装一个DHCP服务器

   072823125.png


   安装失败,在这个时候我们就可以通过查找日志文件来查看哪里安装错误


075515791.jpg


这个时候它提示我们,你这里多了一个“I:我们把这里删除


075639608.png


日志文件还有许多的强大功能我给大家列举了一些:


The facility is one of the followingkeywords: auth, authpriv, cron, daemon, kern, lpr,  mail,  mark, news,  security

     (same as auth), syslog, user, uucp and local0 through local7.  The keyword security should not be usedanymore and mark

     is only for internal use and therefore should not be used inapplications.  Anyway, you may want tospecify  and  redi-

     rect  these  messages here.  The facility specifies the subsystem thatproduced the message, i.e. all mail programs log

     with the mail facility (LOG_MAIL) if they log using syslog.





             # Store critical stuff incritical

             #

             *.=crit;kern.none            /var/adm/critical

所有的除了内核相关的crit这个级别的都会寄到/var/adm/critical


     This will store all messages with the priority crit in the file/var/adm/critical, except for any kernel message.


             # Kernel messages are first, storedin the kernel

             # file, critical messages andhigher ones also go

             # to another host and to theconsole

             #

             kern.*                       /var/adm/kernel

             kern.crit                    @finlandia

             kern.crit                    /dev/console

             kern.info;kern.!err          /var/adm/kernel-info

叹号是取反,也就是infowarning级别的会寄到

     The first rule direct any message that has the kernel facility to thefile /var/adm/kernel.


     The second statement directs all kernel messages of the priority critand higher to the remote host finlandia. This is

     useful,  because if the hostcrashes and the disks get irreparable errors you might not be able to read thestored mes-

     sages.  If they're on a remotehost, too, you still can try to find out the reason for the crash.


     The third rule directs these messages to the actual console, so theperson who works on the machine will get them, too.


     The  fourth line tells the syslogdto save all kernel messages that come with priorities from info up to warningin the

     file /var/adm/kernel-info. Everything from err and higher is excluded.






             # The tcp wrapper loggs withmail.info, we display

             # all the connections on tty12

             #

             mail.=info                   /dev/tty12


     This directs all messages that uses mail.info (in source LOG_MAIL |LOG_INFO) to /dev/tty12,  the  12th console.   For

     example the tcpwrapper tcpd(8) uses this as it's default.


             # Store all mail concerning stuffin a file

             #

             mail.*;mail.!=info           /var/adm/mail


     This pattern matches all messages that come with the mail facility,except for the info priority.  These willbe stored

     in the file /var/adm/mail.


             # Log all mail.info and news.infomessages to info

             #

             mail,news.=info              /var/adm/info


     This will extract all messages that come either  with  mail.info or  with  news.info and  store  them in  the  file

     /var/adm/info.











本文转自 only223wym 51CTO博客,原文链接:http://blog.51cto.com/ymchaofeng/1271707,如需转载请自行联系原作者
相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
目录
相关文章
|
25天前
|
Linux Shell
Linux手动清理Linux脚本日志定时清理日志和log文件执行表达式
Linux手动清理Linux脚本日志定时清理日志和log文件执行表达式
78 1
|
23天前
|
人工智能 安全 Linux
【Linux】Linux之间如何互传文件(详细讲解)
【Linux】Linux之间如何互传文件(详细讲解)
|
18天前
|
存储 监控 安全
Linux系统日志
【4月更文挑战第6天】Linux系统日志,关键用于记录系统状态和事件,包括内核、系统、安全和应用日志,助力管理员诊断问题、确保系统正常运行。日志管理涉及收集、分析、备份等,常用工具如rsyslog、systemd-journal和logrotate(用于日志轮转)。重视日志文件的存储管理,防止空间占用过多。
19 1
Linux系统日志
|
1天前
|
人工智能 Linux
Linux查找大文件的方法
Linux查找大文件的方法
|
3天前
|
固态存储 Ubuntu Linux
Linux(29) 多线程快速解压缩|删除|监视大型文件
Linux(29) 多线程快速解压缩|删除|监视大型文件
11 1
|
3天前
|
Ubuntu Linux 数据安全/隐私保护
Linux(24) 如何在Ubuntu中操作rootfs.img文件
Linux(24) 如何在Ubuntu中操作rootfs.img文件
9 0
|
7天前
|
运维 Oracle 关系型数据库
Oracle日志文件:数据王国的“记事本”
【4月更文挑战第19天】Oracle日志文件是数据库稳定运行的关键,记录数据变更历史,用于恢复和故障处理。它们协调并发操作,确保数据一致性和完整性。日志文件实时写入操作信息并定期刷新到磁盘,便于数据恢复。然而,日志文件需备份和归档以保证安全性,防止数据丢失。日志文件,数据王国的“记事本”,默默守护数据安全。
|
8天前
|
安全 Linux 开发工具
Linux中可引起文件时间戳改变的相关命令
【4月更文挑战第12天】Linux中可引起文件时间戳改变的相关命令
17 0
|
9天前
|
Linux Shell 开发工具
Linux文件常用操作
Linux文件常用操作(几乎覆盖所有日常使用)
84 0
|
11天前
|
SQL 监控 安全
Linux&Windows 日志分析 陇剑杯 CTF
Linux&Windows 日志分析 陇剑杯 CTF