i have an C# application that is writing status information from a PLC device, the program accepts parameters stored in an XML file with a config editor to edit these parameters, the program checks the Memory address of the PLC using the config file to tell the program the address name and datatype etc. if the value changes from previous value then we write the status along with fields from the config to a Log.XML, after testing, this didn’t seem like the best approach as the file was getting large and using lots of cpu to open the Log to check existing value then log new value if changed. the question is what is the best approach for storing config data and log data, the log data is getting written to very frequently, I’m wondering if SQL CE is better performance, if so shall i store config data in SQL as well?
Share
Why not have a buffer, write out to this (which will be much faster than disk). When the buffer reaches a pre-determined size write it out to disk and empty said buffer.
We have a hybrid logging system. If the the customer sets it to logging on, it writes to disk/file. However you can keep the filestream open and write to it. The stream will deal with flushing it out to the concrete file on disk. Don’t open the log file for every line of trace. We also have a fallback if logging is off, this writes to buffer and only if something unexpected happens does it write the buffer out to disk. Its a circular buffer which keeps newest trace lines.