Thursday, 22 August 2013

Create a XML-File in an exception safe and memory friendly way?

Create a XML-File in an exception safe and memory friendly way?

i want to write a Logger/Bug-Tracker (XML) for my current project. I'm
sorry if it should be a duplicate, but the proposals were not useful and i
did not found a good google solution too.
1: My first question is about exception safety.
If i use a XmlDocument the loggs are stored in memory till i call save.
That means i could lose everything in case of an exception.
If i use a XmlWriter it's not stored in memory (afaik) but i have to close
the writer and all elements / nodes which may be a lack in case of an
exception too. Can i close and re-open the writer (with the pointer at the
end of the document) ?
What's the best solution for an exception-safe XML creation ? (I only need
a hint)
2: My second question is about memory usage.
Because it's a tracing tool the output can be very huge. Therefore i can't
use XmlDocument. In my opinion the XmlWriter would be the best solution
for this. Am i right with this ?
3: My last [minor] question is about time consumption.
Is it a good or bad idea to use a XML file for tracing? How much does it
slow down my program ?
I hope you can help me.
Best regards Alex

No comments:

Post a Comment