如何将syslog消息写入数组?

时间:2015-02-24 12:34:05

标签: c# arrays syslog

我有一个代码并获得这样的系统日志消息:

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

1 个答案:

答案 0 :(得分:0)

您必须使用您创建这些消息的业务规则知识编写自定义解析器。没有魔法代码可以帮助您,以及任何了解您要解析的所有可能字符串的程序员。 您不能通过分隔符拆分此行。