/ var / log / messages警报事件级别错误,警告,失败等存储在哪里?

是否存在一个/ var / log / messages事件级别的关键字存储在CentOS 7中的某个系统文件中 ,当通过/ var / log / messages或dmesg进行grep时,将显示所有可能的“string ”等等?

我想使用脚本来search最常见或所有可能的事件,如错误,错误,失败,警告,内核等。

另外,对于日志文件消息,dmesg,cron等,可能的事件是不同的,还是事件关键字通过不同的日志文件都是一样的?

日志优先级根本不存储在/var/log/messages中。

像它的前辈一样, rsyslog使用优先级作为提示来确定在哪里路由任何给定的日志消息。 默认情况下,它不logging优先级本身。

然而,systemd日志确实logging了优先级(并保留了许多其他有趣的元数据)。 您可以使用-p选项来logging日志消息的优先级。

  -p, --priority= Filter output by message priorities or priority ranges. Takes either a single numeric or textual log level (ie between 0/"emerg" and 7/"debug"), or a range of numeric/text log levels in the form FROM..TO. The log levels are the usual syslog log levels as documented in syslog(3), ie "emerg" (0), "alert" (1), "crit" (2), "err" (3), "warning" (4), "notice" (5), "info" (6), "debug" (7). If a single log level is specified, all messages with this log level or a lower (hence more important) log level are shown. If a range is specified, all messages within the range are shown, including both the start and the end value of the range. This will add "PRIORITY=" matches for the specified priorities. 

查看journalctl手册页,了解您可以search日记的所有方法。

在Linux系统上parsing日志文件通常不是微不足道的,因为口号“syslog-compatible”经常被误用( https://en.wikipedia.org/wiki/Syslog )和现有的标准化尝试( https:// tools。 ietf.org/html/rfc3164,https://tools.ietf.org/html/rfc5424 )经常被忽略。

有现有的日志parsing器,可以帮助你的任务。 logstash例如。