tags:

views:

114

answers:

3

Hi! I've got an xml log file formatted with XMLFormatter. I'd like to process this file for report purposes. My problem is, that the log file is not finished by tag, because it is still being written, which makes xml parser bail out.

The log structure is following:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
(...)
</record>
<record>
(...)

Maybe I am missing the point? What's the best strategy for using xml formatted logs?

m.

+3  A: 

The XML logs are for GUI visualizer tools like Chainsaw, which can deal with the incomplete document. They also work well with the EmailAppender which sends each one (hopefully not many) as separate email messages. In most case the text formatters are more useful for human consumption.

Ry4an
A: 

I do something very hackish (bad! bad! bad!), and look for the text '<record>' and the next '</record>', grab everything between, and parse that as one XML document. I feel guilty every time I look at the code, but it does work, at least for the type of data that I am using.

Adam Batkin
A: 

One way to make the XML parser work would be to create a wrapper InputStream that inserts the closing tags into the stream when the read on the wrapped stream returns -1.

Stephen C