如何将系统日志消息写入数组?

How do I write a syslog message into an array?

我有一个代码并收到如下系统日志消息:

May 11 10:40:48 scrooge disk-health-nurse[26783]: [ID 702911 user.error] m:SY-mon-full-500 c:H : partition health measures for /var did not suffice - still using 96% of partition space

是否有代码可以将此代码放入这样的数组中:

array [0] = May 11 10:40:48
array [1] = scrooge
array [2] = scrooge disk-health-nurse[26783]:
array [3] = [ID 702911 user.error]
array [4] = m:SY-mon-full-500
array [5] = c:H : partition health measures for /var did not suffice - still using 96% of partition space

您必须使用您对创建这些消息所依据的业务规则的了解来编写自定义解析器。没有神奇的代码可以帮助您,也没有任何知道您要解析的所有可能字符串的程序员。 你不能只用分隔符分割这一行。