XML-Like Log File Parsing Tools
Has anybody seen a log file format like this before, or know the name of it?
<Msg time='2010-01-10T17:41:31' type='INFO' attrbute3='value' ... >Log Message</Msg>
Right now I am parsing it line by line with a ruby script to get the info I need out, but I was looking into things like Microsoft Log Parser because it has SQL-ish query support.
The only problem is that since all the entries in the log file are like the above example with many top level elements, most tools won't parse it. They complain usually with the error message "Only one 开发者_开发百科top level element is allowed in an XML document."
I could smash it all together into one file with a top level element, but I would rather reuse something existing before going down the rabbit hole even further.
Thanks, Alex
This is an ArcGIS Server log file. The help file that describes them is at help.arcgis.com.
Each dat file has a companion xml file with the same name. This defines the root element for the xml file and references the dat file.
The Log Parser utility will work if you pass the xml file as input. For example, the following statement will write all errors from the ArcGIS Server log into a csv file:
LogParser -i XML -o CSV "SELECT * INTO errors.csv FROM SERVER-SERVER-20120227-000000.xml#/Log/Msg WHERE type='ERROR'"
I ended up having my little log searching tool append a top-node before parsing it so XML tools could interpret it without complaining too much. Used Ruby to parse out the rest and do statistics on what we needed.
精彩评论