Writing to SD cards looks straightforward until you hit power interruptions. I lost enough logs to treat write integrity as a first-class feature.
My format is append-only CSV with periodic file sync. I avoid rewriting headers or metadata during runtime. Each row includes timestamp, sensor IDs, and a checksum column that lets me detect partial lines after reboot.
I also rotate files by size and day. Smaller files recover faster, and data processing scripts run more predictably when logs are chunked.
The final piece is startup repair. On boot, the logger scans the tail of the last file, truncates invalid trailing bytes, and resumes with a new row marker. That keeps datasets usable even after abrupt shutdowns.