I don't know if it would work in your particular case, but you might
be able to avoid this by having the document consist of something
like this:
<!DOCTYPE logfile [
<!ENTITY logentries SYSTEM "logentries">
]>
<logfile>&logentries;</logfile>
and appending elements to the logentries external entity rather than
to the logfile itself.
-- Richard